I want to use Firebase Auth for email/password sign up. The problem is that I only want to accept the user as authenticated when the email address used is also verified.
Normally we can use a listener to check when a user is signed in or no longer signed in:
Auth.auth().addStateDidChangeListener { (auth, user) in
The issue is that this listener is not triggered when the user clicks on the link in the verification email. It's only called once the account is created.
Doing the following in a loop works while waiting for the user to click the link:
Auth.auth().currentUser!.reload() {
if !Auth.auth().currentUser!.isEmailVerified {
but the problem is I ideally want to manage all the auth stuff in the listener callback, but the listener is not used when the email validation state changes.
Is there something I am missing?
I know on mobile you can use deep linking so the link in the mail would open the app again, but that's not what I am looking for as users could open the mail on their computer so the problem still needs to be solved.
For now the only solution I see is to send an nsnotification myself and handle it where I handle all the auth code, but it feels a bit messy.
The first 10K verifications for both instances (USA, Canada, and India and All other countries) are provided at no cost each month. You are only charged on usage past this no-cost allotment. Prices are per successful verification.
After adding his phone number, the user will click on the Get OTP button after that Firebase will send OTP on that number which is mentioned above.
To get the email address of the currently logged in user, use the getAuth function. For email and password / simplelogin you should be able to get the email like this: ref = new Firebase('https://YourFirebase.firebaseio.com'); email = ref. getAuth().
Here are some options:
emailVerified
of a user.emailVerified
in that RTDB node.user.reload()
to update emailVerified
on the user and user.getIdToken(true)
to make sure the token is udpated with the latest claims.Another way is a variation of the above which is to add a continueUrl
which will show a continue button on the default email verification to redirect to a page you own where you know the user is verified. You can also use a similar mechanism as above to pass the status change via real-time database on that page instead of the landing page.
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