Added self-service email changes #46
Loading…
Reference in a new issue
No description provided.
Delete branch "(deleted):main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Allows users to change their own email addresses without needing help from support.
Very cool!! thank you!! The ⚠️ ones are security issues, the rest of them are mostly nitpicks but I still would like to address them before deploying this code.
⚠️ Both
insert_email_update_row
andupdate_email
MUST ensure that thenew_email
is not an email address being used by another user. They should error or otherwise indicate failure in that case. ⚠️⚠️
email_change_confirmation
inauth.py
should have@account_required
. ⚠️For simplicity, I don't think we should put the new email into the URL of the
email_change_confirmation
endpoint. It can just be/change_email/<string:token>
. It should use the flask session to get the original email address (session['account']
).I think
check_email_change_token
andemails_contained_in_row
should be merged into one function.email_change_confirmation
will callnew_email = get_model().check_email_change_token(token, session['account'])
then inside
check_email_change_token
it will run the queryselect new_email from email_updates where token = %s and current_email = $s
We already have a way of validating email addresses that we use in
login
inauth.py
:Validating emails with regex is very difficult and almost always someone will show up with a valid email that fails the regex. I like doing it like this because it's guaranteed never to reject a valid email address.
If you want we could move the email validation into a dedicated function in
shared.py
For code clarity I think it would be better to split this out into 2 functions like so:
and
The
POST
handler can just return a redirect to/account
on success so the code that renders the page doesn't have to be duplicated.This should use
current_app.logger.info(...)
BTW for
check_email_change_token
or any database model method which only runsSELECT
queries, aka its read-only, noUPDATE
,INSERT
, orDELETE
, you don't have to callself.connection.commit()
Pull request closed