klesh commented on code in PR #5127:
URL: 
https://github.com/apache/incubator-devlake/pull/5127#discussion_r1190921347


##########
backend/server/services/auth/cognito.go:
##########
@@ -189,3 +203,52 @@ type Jwks struct {
                E   string `json:"e"`
        } `json:"keys"`
 }
+
+func (cgt *AwsCognitorProvider) NewPassword(newPasswordReq 
*NewPasswordRequest) (*LoginResponse, errors.Error) {
+       input := &cognitoidentityprovider.RespondToAuthChallengeInput{
+               ChallengeName: aws.String("NEW_PASSWORD_REQUIRED"),
+               ChallengeResponses: map[string]*string{
+                       "USERNAME":     aws.String(newPasswordReq.Username),
+                       "NEW_PASSWORD": aws.String(newPasswordReq.NewPassword),
+               },
+               Session:  aws.String(newPasswordReq.Session),
+               ClientId: cgt.clientId,
+       }
+       response, err := cgt.client.RespondToAuthChallenge(input)
+       if err != nil {
+               return nil, errors.BadInput.Wrap(err, "Error setting up new 
password: "+err.Error())
+       }
+       // yes , it is identical to the login response, and yet they are 2 
different structs
+       loginRes := &LoginResponse{
+               ChallengeName:       response.ChallengeName,
+               ChallengeParameters: response.ChallengeParameters,
+               Session:             response.Session,
+       }
+       if response.AuthenticationResult != nil {
+               loginRes.AuthenticationResult = &AuthenticationResult{
+                       AccessToken:  response.AuthenticationResult.AccessToken,
+                       ExpiresIn:    response.AuthenticationResult.ExpiresIn,
+                       IdToken:      response.AuthenticationResult.IdToken,
+                       RefreshToken: 
response.AuthenticationResult.RefreshToken,
+                       TokenType:    response.AuthenticationResult.TokenType,
+               }
+       }
+       return loginRes, nil
+}
+
+// func (cgt *AwsCognitorProvider) ChangePassword(ctx *gin.Context, 
oldPassword, newPassword string) errors.Error {

Review Comment:
   Yes, I'm working ont it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to