-
Notifications
You must be signed in to change notification settings - Fork 378
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
feat: deprecate xxx_token columns from users table (phase iii) #1614
base: master
Are you sure you want to change the base?
Conversation
case mail.EmailChangeVerification: | ||
return mailer.EmailChangeMail(r, u, otpNew, otp, referrerURL, externalURL) |
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.
moved this into it's own function (see sendEmailChangeEmails
because we're passing way too many arguments into the function just to satisfy this case
if we were to combine them, the sendEmail
function would need to take in:
r *http.Request
tx *storage.Connection
u *models.User
emailActionType
otp, otpNew string
ott, ottNew *models.OneTimeToken
where otpNew
and ottNew
are only needed in the email change case.
further refactoring can be done in a subsequent PR to use the ott.TokenType
rather than passing in an emailActionType
internal/api/mail.go
Outdated
if config.Mailer.SecureEmailChangeEnabled && u.GetEmail() != "" { | ||
go func(c chan error) { | ||
c <- mailer.EmailChangeMail(r, u, ottCurrent, otp, referrerURL, externalURL) | ||
}(errors) | ||
} | ||
go func(c chan error) { | ||
c <- mailer.EmailChangeMail(r, u, ottNew, otpNew, referrerURL, externalURL) | ||
}(errors) |
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.
previously, EmailChangeMail
handled multiplexing between the current and new email - i find it alot cleaner for it just to do 1 thing (send the email for email change) and have a separate function that wraps it to decide whether to send 2 emails or just 1 based on whether secure email change is enabled
Pull Request Test Coverage Report for Build 9414598574Details
💛 - Coveralls |
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.
Generally code-wise looks good. I'd reconsider the channel / parallelism introduced for sending emails, but fine either way (so long as we wait for the 2 goroutines to finish).
Pull Request Test Coverage Report for Build 9445054800Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
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.
Thanks!
Pull Request Test Coverage Report for Build 9450374191Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Pull Request Test Coverage Report for Build 10034317134Details
💛 - Coveralls |
What kind of change does this PR introduce?
This PR removes the the reliance on using the
xxx_token
columns in the user model to store information about the token and use theone_time_tokens
table as the single source of truthCreateOneTimeToken
now returns themodels.OneTimeToken
structDecouple sending the email change emails from the
sendEmail
function intosendEmailChangeEmails
This PR does not address changing the
xxx_sent_at
columns to use theone_time_tokens
table yetDo not merge until phase ii has been deployed for some time