12 thoughts on “Ionic 5|4 Firebase Authentication using Email & Password for Login and Registration of Users

  • Another great tutorial. One small tweak: change the generate service command from:

    $ ionic g service services/authentication


    $ ionic g service services/authenticate

    So it matches up with the AuthenticateService name you use for the rest of the tutorial.

    (There is also one mention of the original file path right after the generate command)

  • I would make a small change to allow for trailing whitespace in the email which is often inserted automatically by the phone keyboard.
    Change the email REGEX in the login and register page to:
    Validators.pattern(‘^[a-zA-Z0-9_.+-][email protected][a-zA-Z0-9-]+.[a-zA-Z0-9-.]+\\s*$’)
    Then change the “value.email” on the authentication service to “value.email.trim()”

  • Thank you very much. how can we implement onAuthStateChanged() function, because when you refresh, the Your {{userEmail}} = undefined. but it is still logged in

  • Great article! I have one doubt: if after successful login (with email or some OAuth provider) I need to integrate with a backend, I have to call firebase on all my requests on backend or I can check once and issue a JWT token and use that token for the other calls?
    Keeping in mind I don’t want to use other firebase’s services, just Auth.

    • Hi Marcos, thanks for asking and sharing with others 🙂

      JSON Web Tokens(JWT) is the preferred approach, which you can use for authentication on every server API call while saving user and token details on the client side using sessions. As making firebase authentications, again and again, can prove costly in terms of quota available.

    • I was think of the same thing, hopefully they can update this article. But there’s way you can use gaurd for this matter

Leave a Reply

Your email address will not be published. Required fields are marked *