I'm creating a website where businesses can offer my service to their clients/users for free. For a business to add a user (under their business account), the business logs in and inputs one of their clients/users email. I then send the client/user email to firebase functions and programmatically create an account.
I would like to send this new user a email saying something like 'Account Created: Reset Password' etc., I could do this using sendPasswordResetEmail on the browser, but this function is not available on Firebase functions/admin.
The best option I can think of it to randomly generate a password for each new user (ie - 'ef53gs'), and share the new password in a Welcome Email, but I think it would be a better experience if the Welcome Email included a link to (re)set their password.
Any idea's how to make something like sendPasswordResetEmail work for firebase functions?
To send a password reset email to user, on the Users page, hover over the user and click ... > Reset password. The user will receive an email with instructions on how to reset their password.
To access these parameters, navigate to the 'Users' tab of the 'Authentication' section in the Firebase Console and select 'Password Hash Parameters' from the drop down in the upper-right hand corner of the users table.
We ran into the same issue since the firebase-admin
does not have a sendPasswordResetEmail()
like the firebase
SDK does. We ended up just using the firebase
client SDK on the server as well alongside the firebase-admin
. Works fine.
I think a rather better way to do that is to actually use the REST API to reset the users passwords from the admin without adding a client library to the admin site.
curl 'https://www.googleapis.com/identitytoolkit/v3/relyingparty/getOobConfirmationCode?key=[API_KEY]' \
-H 'Content-Type: application/json' \
--data-binary '{"requestType":"PASSWORD_RESET","email":"[[email protected]]"}'
[API KEY] can be retrieved from Project Settings > add an app >> click web and you will get the configuration with a JSON, within the JSON there is an APIKey that is the one that you need to use.
The admin sdk has a generatePasswordResetLink
which will create the link for you but it's on you then to handle sending the email which you can do using any service you'd like such as mailgun or mandrill. This also gives you more control over the email template.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With