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

Update identities email_verified on email signup #1621

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

janekwunderlich
Copy link

@janekwunderlich janekwunderlich commented Jun 13, 2024

What kind of change does this PR introduce?

This PR fixes a bug where the email_verified field in the identities table is not updated when a user's email is confirmed. This change ensures that the email verification status is correctly reflected in the JWT.

What is the current behavior?

When the user gets an email confirmation link the GET /verify request is called. This goes through the verifyGet method which then calls the signupVerify method. There the AuditLogEntry is created, then the Confirm method on the user is called which updates the confirmation_token and email_confirmed_at, and also clears the OneTimeTokens for the user. However, the email_confirmed field on the identities table does not get updated to true.

#1620

What is the new behavior?

When a GET /verify request is called for a mail signup verification, the signupVerify method now updates the email_verified property to true on the identity_data field on the identities table

@janekwunderlich janekwunderlich requested a review from a team as a code owner June 13, 2024 07:26
@janekwunderlich
Copy link
Author

I think the same is happening for smsVerify and the respective phone_verified fields, do you want me to add this to this PR?

@J0
Copy link
Contributor

J0 commented Jun 14, 2024

Feel free to add it, will give a thorough look to the PR when a slot frees up..

@coveralls
Copy link

coveralls commented Jun 14, 2024

Pull Request Test Coverage Report for Build 9510681514

Details

  • 5 of 15 (33.33%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.02%) to 57.588%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/models/user.go 3 5 60.0%
internal/api/verify.go 2 10 20.0%
Totals Coverage Status
Change from base Build 9487645421: -0.02%
Covered Lines: 8663
Relevant Lines: 15043

💛 - Coveralls

@@ -335,6 +335,18 @@ func (a *API) signupVerify(r *http.Request, ctx context.Context, conn *storage.C
if terr = user.Confirm(tx); terr != nil {
return internalServerError("Error confirming user").WithInternalError(terr)
}

if identity, terr := models.FindIdentityByIdAndProvider(tx, user.ID.String(), "email"); terr != nil {
if !models.IsNotFoundError(terr) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why skip IsNotFoundError? in Signup flow, user and identity will be both inserted, identity record should be found here.

@bqrkhn
Copy link

bqrkhn commented Jul 19, 2024

Hi,

Face this issue while working with Supabase auth. Any update on this?

Discord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants