- Angular app with Firebase Authentication that displays a dashboard with login, logout, forgot-password etc. buttons & routing
- User details stored in a Cloud Firestore database
- Tutorial code from D-I-Ry with some modifications - see 👏 Inspiration below
- Note: to open web links in a new window use: ctrl+click on link
- Firebase authentication used to identify user
- This is not a practical auth. dashboard - too many buttons displayed. I had to modify the code not to display login and logout button together, for example.
- Angular v14
- rxjs v7 Reactive Extensions Library for JavaScript
- firebase v9 backend
- @angular/fire v7 Angular library for Firebase.
- Create project in Firebase console then add email authentication.
npm i
to install dependenciesnpm prune
to remove unused npm modulesng serve
for a dev server. Navigate tohttp://localhost:4200/
. The app will automatically reload if you change any of the source files.ng update
to update Angular
💻 Code Examples - by D-I-Ry with some modifications
- login function that signs in user with details from html form
loginUser(email: string, password: string): Promise<any> {
return this.afAuth
.signInWithEmailAndPassword(email, password)
.then(() => {
console.log('Auth Service: loginUser: success');
this.router.navigate(['/dashboard']);
})
.catch((error) => {
console.log('Auth Service: login error code', error.code, error);
if (error.code) return { isValid: false, message: error.message };
return { isValid: true, message: 'no errors :-)' };
});
}
- 'Verify email' actually works and sends an email to the user with a link to click on. Refresh required to change boolean state on screen. Firebase backend code does make things easier.
- Status: Working
- To-Do: Nothing
- N/A
- Repo created by ABateman, email: gomezbateman@yahoo.com