Skip to content

Commit

Permalink
fix: add checks for cases where more than 1 identity is returned
Browse files Browse the repository at this point in the history
  • Loading branch information
kangmingtay committed Dec 12, 2024
1 parent be64d0a commit 5ddfe54
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/api/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,13 @@ func (a *API) signupVerify(r *http.Request, ctx context.Context, conn *storage.C
//
// we still check for the length of the identities slice to be safe.
if len(user.Identities) != 0 {
if len(user.Identities) > 1 {
return internalServerError("User has more than one identity on signup")
}
emailIdentity := user.Identities[0]
if emailIdentity.Email != user.Email {
return internalServerError("User email identity does not match user email")
}
if terr = emailIdentity.UpdateIdentityData(tx, map[string]interface{}{
"email_verified": true,
}); terr != nil {
Expand Down
1 change: 1 addition & 0 deletions internal/api/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (ts *VerifyTestSuite) SetupTest() {
// Create identity
i, err := models.NewIdentity(u, "email", map[string]interface{}{
"sub": u.ID.String(),
"email": "[email protected]",
"email_verified": false,
})
require.NoError(ts.T(), err, "Error creating test identity model")
Expand Down

0 comments on commit 5ddfe54

Please sign in to comment.