Skip to content

Commit 307892f

Browse files
authored
feat: set email_verified to true on all identities with the verified email (#1902)
A fix for #1899 undoing changes in #1868.
1 parent 871195f commit 307892f

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

internal/api/verify.go

+7-13
Original file line numberDiff line numberDiff line change
@@ -329,24 +329,18 @@ func (a *API) signupVerify(r *http.Request, ctx context.Context, conn *storage.C
329329
return internalServerError("Error confirming user").WithInternalError(terr)
330330
}
331331

332-
// on signupVerify, the user will always only have an email identity
333-
// so we can safely assume that the first identity is the email identity
334-
//
335-
// we still check for the length of the identities slice to be safe.
336-
if len(user.Identities) != 0 {
337-
if len(user.Identities) > 1 {
338-
return internalServerError("User has more than one identity on signup")
332+
for _, identity := range user.Identities {
333+
if identity.Email == "" || user.Email == "" || identity.Email != user.Email {
334+
continue
339335
}
340-
emailIdentity := user.Identities[0]
341-
if emailIdentity.Email != user.Email {
342-
return internalServerError("User email identity does not match user email")
343-
}
344-
if terr = emailIdentity.UpdateIdentityData(tx, map[string]interface{}{
336+
337+
if terr = identity.UpdateIdentityData(tx, map[string]interface{}{
345338
"email_verified": true,
346339
}); terr != nil {
347-
return internalServerError("Error updating email identity").WithInternalError(terr)
340+
return internalServerError("Error setting email_verified to true on identity").WithInternalError(terr)
348341
}
349342
}
343+
350344
return nil
351345
})
352346
if err != nil {

0 commit comments

Comments
 (0)