Skip to content

Commit 7e472ad

Browse files
authored
fix: add token to hook payload for non-secure email change (#1763)
## What kind of change does this PR introduce? Fix #1744 by introducing the token to the Auth Hook payload for Send Email. The tokenHash seems to be already present. Currently, it's passed into the function as `otpNew`. Though it is indeed the OTP needed to validate the new email address we place it in the `token` field to maintain the convention that `token_hash_new` is only populated when secure email change is enabled New output structure: <img width="598" alt="image" src="https://github.com/user-attachments/assets/a8c44214-dcf2-4d2e-a653-b3953244ac69">
1 parent a6c1824 commit 7e472ad

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

internal/api/mail.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,11 @@ func (a *API) sendEmail(r *http.Request, tx *storage.Connection, u *models.User,
608608
}
609609

610610
if config.Hook.SendEmail.Enabled {
611+
// When secure email change is disabled, we place the token for the new email on emailData.Token
612+
if emailActionType == mail.EmailChangeVerification && !config.Mailer.SecureEmailChangeEnabled && u.GetEmail() != "" {
613+
otp = otpNew
614+
}
615+
611616
emailData := mail.EmailData{
612617
Token: otp,
613618
EmailActionType: emailActionType,

0 commit comments

Comments
 (0)