Skip to content

πŸ“‹ Firebase user authentication service, tutorial from Stephen Fluin, Demos with Angular

License

Notifications You must be signed in to change notification settings

AndrewJBateman/angular-firebase-auth-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

b4499c5 Β· Jan 29, 2023

History

31 Commits
Jul 12, 2020
Apr 14, 2019
Jan 29, 2023
Dec 16, 2018
Feb 11, 2022
Feb 11, 2022
Jun 11, 2021
Jan 29, 2023
May 23, 2022
Jan 29, 2023
Jan 29, 2023
Jan 29, 2023
Jul 12, 2020

Repository files navigation

⚑ Angular Firebase Auth Service

  • User authentication app using Angular and google Firebase.
  • Note: to open web links in a new window use: ctrl+click on link

GitHub repo size GitHub pull requests GitHub Repo stars GitHub last commit

πŸ“„ Table of contents

πŸ“š General info

  • This is just for development, not production, so the whole firebase module is used.

πŸ“· Screenshots

Example screenshot.

πŸ“Ά Technologies

πŸ’Ύ Setup

  • Install dependencies with npm i
  • Create google firebase project with Sign-in provider as Google and paste access keys from Project Settings into environment.ts
  • Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files

πŸ’» Code Examples

  • user.service file
@Injectable({
  providedIn: 'root'
})
export class UserService {
  uid = this.afAuth.authState.pipe(
    map(authState => {
      if (!authState) {
        return null;
      } else {
        return authState.uid;
      }
    })
  );
  //test to see if already logged in
  isAdmin: Observable<boolean> = this.uid.pipe(
    switchMap(uid => {
      if (!uid) {
        return observableOf(false);
      } else {
        return this.db.object<boolean>('/admin/' +uid).valueChanges();
      }
    })
  );
  //test to see if user has specific permissions
  constructor(private afAuth: AngularFireAuth, private db: AngularFireDatabase) { }
  login() {
    this.afAuth.auth.signInWithPopup(new auth.GoogleAuthProvider());
  }
  logout() {
    this.afAuth.auth.signOut();
  }
}

πŸ†’ Features

  • user login using google id or password, can be viewed on Firebase Console.
  • User privileges can be revoked from the Firebase console.

πŸ“‹ Status & To-Do List

  • Status: Working
  • To-Do: add theme colors and functionality. A bootstrap button would be better.

πŸ‘ Inspiration

πŸ“ License

  • This project is licensed under the terms of the MIT license.

βœ‰οΈ Contact