I'm developing an application and I need to implement a feature that allows users to change their email addresses while they're signed in. I have a basic workflow in mind: the user will update their email, save the changes, and then an OTP (One-Time Password) will be sent to their new email for verification. Once they enter the OTP, the email should change and they will log in with the new email going forward. I'm wondering if there are any security considerations I might be overlooking? How do other applications handle this kind of functionality, and can anyone suggest any additional measures to ensure security? Any references to apps that manage this well would be helpful too.
2 Answers
Consider the various threats related to email changes. For example, an unauthorized person might try to change the email to one they control, so informing the old email owner about the change is key. Also, if a user leaves their account logged in on a public computer, you should make it difficult for someone to steal their account by requiring a password re-entry before they can change the email. When implementing this, focus on strengthening password recovery measures and always send notifications about any changes made.
Your approach is good, but don't forget a couple of important steps! Many apps send a confirmation email to the OLD email address to inform the user about the change. It’s also common to ask users to verify their current password before making this change. Additionally, think about cases where someone starts the email change but doesn't finish the OTP verification—should you keep the old email active or lock the account? Most would keep it active until the new email is fully verified.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically