I writing a security layer for my app and I would like your input on updating users' email addresses (also used for the login).
I'm interested to hear from anyone who has written an application with similar requirements. How would you go about it? Here are some ways I thought of, but I suspect I'm missing something:
Approach one
- Update the address and send a confirmation email to the new address
- If address is not confirmed with 48 hours, suspend it
- It's easy.
- If new address is wrong, the user gets locked out of account.
- Someone can hijack the account by changing the user's address.
Approach two
- Update the address and store the old value temporarily
- Send a notification email to the old address with an option to revoke the change
- Send a confirmation email to the new address
- I restore the old address if the user revokes the change (through the notification email)
If the change is not revoked, but the new address is not confirmed within 48 hours, I suspend the account.
- Secure
- A lot more work
Approach three
- Do not update the address but store the new value temporarily
- Send a confirmation email to the old address asking to confirm the change.
- If the change is confirmed, carry out the update and send a confirmation email to the new address.
If new address is not confirmed with 48 hours, suspend the account.
- Secure
- A lot more work
It's best to be as secure as possible, but I don't want to put the user off by giving them 1001 things to do just to change an email address.
They might also have secondary email addresses, not used for login, but for other purposes, and I'm not sure how to handle updates to those addresses. Ideas are welcomed.