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

Commit

Permalink
fix: fix RegisterByPhoneCode Password Rsa error
Browse files Browse the repository at this point in the history
  • Loading branch information
luojielin committed Apr 25, 2023
1 parent a0a2c4e commit 7cf0827
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/authentication/authentication_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ func (c *Client) BuildAuthorizeUrlByOidc(params model.OidcParams) (string, error
}

// GetAccessTokenByCode
// code 换取 accessToken
//
// code 换取 accessToken
func (c *Client) GetAccessTokenByCode(code string) (string, error) {
if c.AppId == "" {
return constant.StringEmpty, errors.New("请在初始化 AuthenticationClient 时传入 appId")
Expand Down Expand Up @@ -144,7 +145,8 @@ func (c *Client) GetUserInfoByAccessToken(accessToken string) (string, error) {
}

// GetNewAccessTokenByRefreshToken
// 使用 Refresh token 获取新的 Access token
//
// 使用 Refresh token 获取新的 Access token
func (c *Client) GetNewAccessTokenByRefreshToken(refreshToken string) (string, error) {
if c.Protocol != constant.OIDC && c.Protocol != constant.OAUTH {
return constant.StringEmpty, errors.New("初始化 AuthenticationClient 时传入的 protocol 参数必须为 ProtocolEnum.OAUTH 或 ProtocolEnum.OIDC,请检查参数")
Expand Down Expand Up @@ -338,7 +340,7 @@ func (c *Client) LoginByPhonePassword(request model.LoginByPhonePasswordInput) (
return c.loginGetUserInfo(b, "loginByPhonePassword")
}

//TODO
// TODO
func (c *Client) loginGetUserInfo(b []byte, userKey string) (*model.User, error) {
var result *simplejson.Json
result, err := simplejson.NewJson(b)
Expand Down Expand Up @@ -435,7 +437,7 @@ func (c *Client) SendHttpRequestManage(url string, method string, query string,
return body, nil
}

//TODO
// TODO
func QueryAccessToken(client *Client) (*model.AccessTokenRes, error) {
type Data struct {
AccessToken model.AccessTokenRes `json:"accessToken"`
Expand Down Expand Up @@ -673,6 +675,10 @@ func (c *Client) RegisterByUsername(request *model.RegisterByUsernameInput) (*mo
// 使用手机号及验证码注册
func (c *Client) RegisterByPhoneCode(request *model.RegisterByPhoneCodeInput) (*model.User, error) {

if request.Password != nil {
var pwd = util.RsaEncrypt(*request.Password)
request.Password = &pwd
}
data, _ := jsoniter.Marshal(request)
variables := make(map[string]interface{})
jsoniter.Unmarshal(data, &variables)
Expand Down Expand Up @@ -1584,8 +1590,8 @@ func (c *Client) ValidateTicketV1(ticket, service string) (*struct {
return resp, nil
}

//BuildLogoutUrl
//拼接登出 URL
// BuildLogoutUrl
// 拼接登出 URL
func (c *Client) BuildLogoutUrl(expert, redirectUri, idToken *string) string {
var url string
if c.Protocol == constant.OIDC {
Expand Down

0 comments on commit 7cf0827

Please sign in to comment.