Skip to content

Commit

Permalink
feat: set email_verified to true on all identities with the verifie…
Browse files Browse the repository at this point in the history
…d email (#1902)

A fix for #1899 undoing changes in #1868.
  • Loading branch information
hf authored Jan 6, 2025
1 parent 871195f commit 307892f
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions internal/api/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,24 +329,18 @@ func (a *API) signupVerify(r *http.Request, ctx context.Context, conn *storage.C
return internalServerError("Error confirming user").WithInternalError(terr)
}

// on signupVerify, the user will always only have an email identity
// so we can safely assume that the first identity is the email identity
//
// 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")
for _, identity := range user.Identities {
if identity.Email == "" || user.Email == "" || identity.Email != user.Email {
continue
}
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{}{

if terr = identity.UpdateIdentityData(tx, map[string]interface{}{
"email_verified": true,
}); terr != nil {
return internalServerError("Error updating email identity").WithInternalError(terr)
return internalServerError("Error setting email_verified to true on identity").WithInternalError(terr)
}
}

return nil
})
if err != nil {
Expand Down

0 comments on commit 307892f

Please sign in to comment.