Skip to content

Instantly share code, notes, and snippets.

@fulviodenza
Created January 18, 2022 14:28
Show Gist options
  • Save fulviodenza/5b811cecb42bf27e8254d6a477a14365 to your computer and use it in GitHub Desktop.
Save fulviodenza/5b811cecb42bf27e8254d6a477a14365 to your computer and use it in GitHub Desktop.
func (a *App) OTP(c echo.Context) (err error) {
r := new(Response)
o := new(OTP)
if err = c.Bind(o); err != nil {
return echo.NewHTTPError(http.StatusBadRequest, err.Error())
}
if err = c.Validate(o); err != nil {
return err
}
user := &cognito.ConfirmSignUpInput{
ConfirmationCode: aws.String(o.OTP),
Username: aws.String(o.Username),
ClientId: aws.String(a.AppClientID),
}
secretHash := computeSecretHash(a.AppClientSecret, o.Username, a.AppClientID)
user.SecretHash = aws.String(secretHash)
_, r.Error = a.CognitoClient.ConfirmSignUp(user)
if err != nil {
fmt.Println(err)
return c.JSON(http.StatusInternalServerError, r)
}
return c.JSON(http.StatusOK, r)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment