npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-firebase-auth

v1.2.6

Published

Simple lightweight Firebase Authentication Service for Angular 12+

Downloads

22

Readme

NgxFirebaseAuth

Open Source Library for Angular Web Apps to integrate a simple firebase authentication service. Supporting @angular v13.2.1

Install

npm install ngx-firebase-auth

Peer dependencies

|Package| Version|
|---|---| | @angular/core | >=11.0.x <=13.2.x | | @angular/fire | 7.2.0 | | firebase| 9.6.6 | | rxjs| >=6.5.x <=7.4.x |

Features

|Feature| |
|---|:---:| | createUserWithEmailAndPassword | :heavy_check_mark:| | signInWithEmailAndPassword | :heavy_check_mark: | | signOut| :heavy_check_mark: | | sendEmailVerification| :heavy_check_mark: | | reauthenticateWithCredential| :heavy_check_mark: |

Usage

To use the Service just inject it in the constructor like every other service

constructor(private authService: NgxFirebaseAuthService) {
    // some code
}

To register

/* 
    Assume that there are two inputs in HTML (email and password) and 
    we call the function on button press with the input values as parameters
*/

private register(emailInput: string, passwordInput: string): void {
    const context: AuthContext = {
      email: emailInput,
      password: passwordInput,
    };
    this.authService.register(context).then((user: UserCredential) => {
      console.log(user);
    }).catch((e) => {
      console.error(e);
    });
  }

To log in

/* 
    Assume that there are two inputs in HTML (email and password) and 
    we call the function on button press with the input values as parameters
*/

private (emailInput: string, passwordInput: string): void {
    const context: AuthContext = {
      email: emailInput,
      password: passwordInput,
    };
    this.authService.login(context).then((user: UserCredential) => {
      console.log(user);
    }).catch((e) => {
      console.error(e);
    });
  }

Functions

Note:
UserCredential = firebase.auth.UserCredential
FirebaseUser = firebase.User

|Type | Name | Description | Return Value |
|---|---|---|---| | getter | currentUser$ | Get the current User Observable from AngularFireAuth | Observable<FirebaseUser> | | getter |currentUser | Gets the current user if authenticated | FirebaseUser or null | | getter |currentUserId | Gets the current user id if authenticated | string or null | | getter |authenticated | Checks if user is authenticated | boolean | | getter |isVerified | Checks if user email is verified | boolean | | function|register(context: AuthContext) | Register the user | Promise<UserCredential> | | function|login(context: AuthContext) | Login the user | Promise<UserCredential> | | function|logout() | Logs out the user and clear credentials. | Promise<void> | | function|sendEmailVerification() | Sends Email Verification e.g. after registration. | Promise<void> | | function|sendPasswordResetEmail(email: string) | Sends reset password mail | Promise<void> | | function|reauthenticateUser(password: string) | Reauthenticate an user, e.g. when updating user email | Promise<FirebaseUser> |

Interfaces

interface AuthContext {
  email: string;
  password: string;
}

FAQ

Error TS2344: Type 'T[K]' does not satisfy the constraint

Add the following line in your main tsconfig.json inside compilerOptions:

"skipLibcheck": true

Build by and for developers

Feel free to provide a PR | open an appropriate issue here If you like this project, support ngx-firebase-auth by starring :star: and sharing it :loudspeaker: