Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
新增停用账号,解除停用,离职用户能力
Browse files Browse the repository at this point in the history
  • Loading branch information
luojielin committed Mar 28, 2022
1 parent 7a54d30 commit 9efdfe8
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 6 deletions.
42 changes: 42 additions & 0 deletions lib/management/user_management_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -957,3 +957,45 @@ func (c *Client) GetUserTenants(userId string) (*model.GetUserTenantsResponse, e
}
return &resp.Data, nil
}

//SuspendUser
//停用账号
func (c *Client) SuspendUser(userId string) (*model.CommonMessageAndCode, error) {
url := fmt.Sprintf("%v/api/v2/users/%v/suspend", c.Host, userId)
json := make(map[string]interface{})
b, err := c.SendHttpRequest(url, http.MethodPost, "", json)
if err != nil {
return nil, err
}
var response model.CommonMessageAndCode
jsoniter.Unmarshal(b, &response)
return &response, nil
}

//ActivateUser
//解除停用账号
func (c *Client) ActivateUser(userId string) (*model.CommonMessageAndCode, error) {
url := fmt.Sprintf("%v/api/v2/users/%v/activate", c.Host, userId)
json := make(map[string]interface{})
b, err := c.SendHttpRequest(url, http.MethodPost, "", json)
if err != nil {
return nil, err
}
var response model.CommonMessageAndCode
jsoniter.Unmarshal(b, &response)
return &response, nil
}

//ResignUser
//离职用户
func (c *Client) ResignUser(userId string) (*model.CommonMessageAndCode, error) {
url := fmt.Sprintf("%v/api/v2/users/%v/resign", c.Host, userId)
json := make(map[string]interface{})
b, err := c.SendHttpRequest(url, http.MethodPost, "", json)
if err != nil {
return nil, err
}
var response model.CommonMessageAndCode
jsoniter.Unmarshal(b, &response)
return &response, nil
}
42 changes: 36 additions & 6 deletions lib/management/user_management_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"reflect"
"testing"

"github.com/Authing/authing-go-sdk/lib/enum"
"github.com/Authing/authing-go-sdk/lib/model"
)

Expand All @@ -30,12 +29,10 @@ func TestClient_GetUserInfo(t *testing.T) {
func TestClient_GetUserList(t *testing.T) {
client := NewClient(userPoolId, appSecret)
log.Println("==========导出所有组织机构数据==========")
custom := true
//custom := true
req := model.QueryListRequest{
Page: 1,
Limit: 10,
SortBy: enum.SortByCreatedAtAsc,
WithCustomData: &custom,
Page: 1,
Limit: 10,
}
resp, _ := client.GetUserList(req)
log.Printf("%+v\n", resp)
Expand Down Expand Up @@ -476,3 +473,36 @@ func TestClient_GetUserTenants(t *testing.T) {
}
log.Printf("%+v\n", resp)
}

func TestClient_SuspendUser(t *testing.T) {
client := NewClient(userPoolId, appSecret)
log.Println("==========停用账号==========")

resp, err := client.SuspendUser("623946dd3615b3a2ee65832d")
if err != nil {
log.Println(err)
}
log.Printf("%+v\n", resp)
}

func TestClient_ActivateUser(t *testing.T) {
client := NewClient(userPoolId, appSecret)
log.Println("==========停用账号==========")

resp, err := client.ActivateUser("623946dd3615b3a2ee65832d")
if err != nil {
log.Println(err)
}
log.Printf("%+v\n", resp)
}

func TestClient_ResignUser(t *testing.T) {
client := NewClient(userPoolId, appSecret)
log.Println("==========停用账号==========")

resp, err := client.ResignUser("623946dd3615b3a2ee65832d")
if err != nil {
log.Println(err)
}
log.Printf("%+v\n", resp)
}

0 comments on commit 9efdfe8

Please sign in to comment.