-
Notifications
You must be signed in to change notification settings - Fork 387
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: set hook for email change when only phone identity present #1865
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -650,21 +650,22 @@ func (a *API) sendEmail(r *http.Request, tx *storage.Connection, u *models.User, | |
} | ||
|
||
if config.Hook.SendEmail.Enabled { | ||
// When secure email change is disabled, we place the token for the new email on emailData.Token | ||
if emailActionType == mail.EmailChangeVerification && !config.Mailer.SecureEmailChangeEnabled && u.GetEmail() != "" { | ||
otp = otpNew | ||
} | ||
|
||
emailData := mail.EmailData{ | ||
Token: otp, | ||
EmailActionType: emailActionType, | ||
RedirectTo: referrerURL, | ||
SiteURL: externalURL.String(), | ||
TokenHash: tokenHashWithPrefix, | ||
} | ||
if emailActionType == mail.EmailChangeVerification && config.Mailer.SecureEmailChangeEnabled && u.GetEmail() != "" { | ||
emailData.TokenNew = otpNew | ||
emailData.TokenHashNew = u.EmailChangeTokenCurrent | ||
if emailActionType == mail.EmailChangeVerification { | ||
// When secure email change is disabled, we place the token for the new email on emailData.Token | ||
if !config.Mailer.SecureEmailChangeEnabled { | ||
// Token Hash should already be set above | ||
emailData.Token = otpNew | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this mean that the actual value in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Value in |
||
} else { | ||
emailData.TokenNew = otpNew | ||
emailData.TokenHashNew = u.EmailChangeTokenCurrent | ||
} | ||
} | ||
input := hooks.SendEmailInput{ | ||
User: u, | ||
|
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.
what is the initial value of
otp
here?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 be
""
if there's secure email change is not enabled. If it's enabled, and there's no phone linked to it it doesn't get set so it remains as""
.ref