Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate recover email link in firebase

Is there any way to create custom recoverEmail link in firebase/firebase-admin?

I've checked the docs and tutorials there's none. Any help would be great!

like image 578
Reyn Avatar asked Sep 12 '25 20:09

Reyn


1 Answers

From my understanding there is currently no solution for this within the SDK. Instead, we took the approach of using admin.auth().generateSignInWithEmailLink(email, actionCodeSettings) and then replacing the mode within the returned link from signIn to recoverEmail.

const updatedLink = link.replace('signIn', 'recoverEmail');

This allowed us to customise the auth handler action as suggested here Create the email action handler page in the Firbase documentation.

Now we are able to call on admin.auth().updateUser again to reset the email to it's previous, along with update across our databases, merchant and other services. You'll also need to add the original email to a query in the updatedLink too.

const linkWithOriginalEmail = updatedLink.concat(`&email=${email}`)

Hope that helps and if anyone has a better solution we'd love to discuss.

like image 60
Darren Avatar answered Sep 15 '25 11:09

Darren