-
Notifications
You must be signed in to change notification settings - Fork 394
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
Fix: email change improvements #132
Conversation
go func(e, t string) { | ||
data := map[string]interface{}{ | ||
"SiteURL": m.Config.SiteURL, | ||
"ConfirmationURL": url, | ||
"Email": user.GetEmail(), | ||
"NewEmail": user.EmailChange, | ||
"Token": t, | ||
"Data": user.UserMetaData, | ||
} | ||
errors <- m.Mailer.Mail( | ||
e, | ||
string(withDefault(m.Config.Mailer.Subjects.EmailChange, "Confirm Email Change")), | ||
m.Config.Mailer.Templates.EmailChange, | ||
defaultEmailChangeMail, | ||
data, | ||
) | ||
}(email, token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Send emails concurrently via goroutines since they don't have to be sequential
for i := 0; i < len(tokens); i++ { | ||
e := <-errors | ||
if e != nil { | ||
return e | ||
} | ||
} | ||
|
||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check if any of the goroutines experienced an error sending the email
models/user.go
Outdated
@@ -341,6 +352,11 @@ func FindUserByRecoveryToken(tx *storage.Connection, token string) (*User, error | |||
return findUser(tx, "recovery_token = ?", token) | |||
} | |||
|
|||
// FindUserByRecoveryToken finds a user with the matching recovery token. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update comment?
|
||
DO $$ | ||
BEGIN | ||
IF NOT EXISTS(SELECT * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be IF EXISTS
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yeah you're right, i forgot to remove my docker volume after making the change manually so i thought the migration worked 😅
THEN | ||
ALTER TABLE "auth"."users" RENAME COLUMN "email_change_token" TO "email_change_token_new"; | ||
END IF; | ||
END $$; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: add newline at end of file?
🎉 This PR is included in version 2.0.11 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Fix: email change improvements
What kind of change does this PR introduce?
Addresses #60 and #78
What is the current behavior?
Email change verification is broken.
What is the new behavior?
Allows a user to change their email. Requires the user's jwt access token to call
PUT /user
.For security reasons, we send out 2 emails when a user makes an update email request:
The user needs to log into both email accounts and verify by clicking both links.
Design
email_change_token_current
: Keeps track of token sent to current emailemail_change_token_new
: Keeps track of token sent to new emailemail_change_confirm_status
: Keeps track of the number of verified email (0, 1, 2)Additional context
Adds
/verify?type=email_change
to handle email change verification logic.