Search code examples
angularfirebasefirebase-authenticationangularfire2

How to verify email and change password with a different email service than what Firebase provided?


I am working on an Angular project, it uses Firebase to handle authentication and data storage.

But since Firebase email doesn't allow custom, fancy templates, I want to use a different email service but I can't figure out how exactly to use functions like 'auth.confirmPasswordReset' for Forgot Password and 'auth.applyActionCode'.

Problem with Forgot Password is, to able to change password without an email code, user needs to be authenticated but to be authenticated, they need to know their password. I don't know if I can forcefully change a user's password in Firebase, just by knowing their email, after confirming my own custom token sent by the third party app.

Problem with Email Verification feels easier, user needs to be authenticated to confirm their account's email anyway but instead of using action code, I need to write my own function that will confirm the validity of verification code and if the code is valid, function will change "emailVerified" value in user from false to true. Problem is, this doesn't seem possible or I can't find any function that allows me to do that.

Is it possible to do any of this or is using different email services impossible with Firebase?


Solution

  • The simplest way to implement your own password reset these days, is to completely implement your own flow, and then use the Admin SDK to set the user's emailVerified property to true. For example in Node.js this is as simple as:

    admin.auth().updateUser(uid, { emailVerified: true })
    

    This functionality is only available in the Firebase Admin SDKs, which means that you should only run it on a trusted environment, such as your development machine, a server you control, or Cloud Functions.