Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: set email_verified to true on all identities with the verified email #1902

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading