Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to do email confirmation for Firebase user creation and/or password reset?

Question says it all. In Firebase, how do I confirm email when a user creates an account, or, for that matter, do password reset via email.

I could ask more broadly: is there any way to send emails out from Firebase? E.g. notifications, etc. This isn't the kind of thing you would usually do client-side.

like image 845
deitch Avatar asked Jul 18 '13 12:07

deitch


People also ask

How does Firebase email verification work?

You can use Firebase Authentication to sign in a user by sending them an email containing a link, which they can click to sign in. In the process, the user's email address is also verified. There are numerous benefits to signing in by email: Low friction sign-up and sign-in.

Does Firebase charge for email verification?

So you don't pay for verifying an email address, nor for each API call you make, but only for completed verifications through the code that was sent in the SMS message.


1 Answers

Update

Note that this was never a very secure way of handling email verification, and since Firebase now supports email verification, it should probably be used instead.

Original answer

I solved the email verification using the password reset feature.

On account creation I give the user a temporary (randomly generated) password. I then trigger a password reset which will send an email to the user with a link. The link will allow the user to set a new password.

To generate a random password you can use code similar to this:

function () {   var possibleChars = ['abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!?_-'];   var password = '';   for(var i = 0; i < 16; i += 1) {     password += possibleChars[Math.floor(Math.random() * possibleChars.length)];   }   return password; } 

Note that this is happening on the client, so a malicious user could tamper with your logic.

like image 123
amcdrmtt Avatar answered Sep 20 '22 19:09

amcdrmtt