Firebase Authentication

Hong Ly
3 min readJan 16, 2021

--

Most applications require to know the identity of a particular user. By knowing a user’s identity, it allows the app to securely store user’s data in the cloud and provides the same personalized experience across all of the user’s devices.

Firebase Authentication provides backend services, easy-to-use SDKs, and ready-made UI libraries that can be used to authenticate each user on the app. It also supports authentication using usernames, passwords and so on [1].

To implement Firebase Authentication into the app, I need to write the codes in app.component.ts as follows.

Sign Out Feature

To sign user out of the app. In services -> auth.ts, I will need to write the logout function as below.

Now in app.component.ts, I need to import AuthService in order to use the logout function.

Firebase Stores Token

To see the token that is stored by Firebase, click on >> symbol then Application.

Now navigate to Local Storage then click on http:/localhost:8100. At the moment there are no key and value stored.

Once the user is signed into the app, Firebase stores the particular user’s key and value (token) within the app.

The token will be deleted once a user is signed out from the app and, it will redirect to the sign in page again.

References

[1] Firebase. (2017). Firebase Authentication | Firebase. [online] Available at: https://firebase.google.com/docs/auth/ [Accessed 25 Aug. 2017].

--

--

Hong Ly
Hong Ly

Written by Hong Ly

Content Creator & Software Engineer

No responses yet