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

@g.plymenos/ng-firebase-auth

v0.0.7

Published

An Angular Firebase UI Implementation with Custom Email Sign In/Sign Up

Downloads

9

Readme

Description

This is an implementation of FirebaseUi Auth component for Angular with a custom Sing In/Sign up form using a Angular Material Dialog.

How to Implement into your Angular Projects

Into your existing angular project install firebase and firebase-ui

$ npm install firebase firebaseui @angular/fire firebaseui-angular
$ npm install @angular/material
$ npm install @g.plymenos/ng-firebase-auth

In your angular.json file add any prefered Material theme and firebaseui styles under styles for build and test:

"node_modules/firebaseui/dist/firebaseui.css", "@angular/material/prebuilt-themes/indigo-pink.css";

Create an environment.ts file and add firebase config provided when creating a Firebase project (https://firebase.google.com/docs/web/learn-more?hl=en&authuser=0)

export const firebaseConfig: FirebaseConfig = {
  projectId: "",
  appId: "",
  apiKey: "",
  authDomain: "",
  storageBucket: "",
  messagingSenderId: "",
  measurementId: "",
};

Create a firebaseUiAuthConfig.ts file and add a firebaseUiConfig of type firebaseui.auth.Config. This file is the firebaseUi component configuration. For more info follow the link (https://github.com/firebase/firebaseui-web)

import { FirebaseUIModule, firebase, firebaseui } from "firebaseui-angular";

export const firebaseUiAuthConfig: firebaseui.auth.Config = {
  signInFlow: "popup",
  signInOptions: [
    firebase.auth.GoogleAuthProvider.PROVIDER_ID,
    {
      scopes: ["public_profile", "email", "user_likes", "user_friends"],
      customParameters: {
        auth_type: "reauthenticate",
      },
      provider: firebase.auth.FacebookAuthProvider.PROVIDER_ID,
    },
    firebase.auth.TwitterAuthProvider.PROVIDER_ID,
  ],
  tosUrl: "<your-tos-link>",
  privacyPolicyUrl: "<your-privacyPolicyUrl-link>",
  credentialHelper: firebaseui.auth.CredentialHelper.GOOGLE_YOLO,
};

Initialise your firebase Angular Module and FirebaseUi Module in your ngModule or appConfig depending on your Angular setup

import { AngularFireModule } from "@angular/fire/compat";
import { FirebaseUIModule } from "firebaseui-angular";
import { AuthModule } from "auth";
import { firebaseUiAuthConfig } from "../firebaseUi.config";
import { firebaseConfig } from "../environment";

AuthModule, AngularFireModule.initializeApp(firebaseConfig), FirebaseUIModule.forRoot(firebaseUiAuthConfig);

Implement the Firebase Component into a Material Modal

import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
import { AuthService, FirebaseuiAuthComponent } from 'auth'

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [RouterOutlet],
  templateUrl: './app.component.html',
  styleUrl: './app.component.scss'
})
export class AppComponent {
  constructor(private firebaseAuthService: AuthService, private dialog: MatDialog) {}

  openAuthModal() {
    this.dialog.open(FirebaseuiAuthComponent);
  }
}

If you would like to know when a user is loggedin/Loggedout and display information you can subscribe user changes as below:

this.loggedUserSubscription = this.firebaseAuthService.getLoggedUserUpdates().subscribe((user) => {
  console.log("user");
  console.log(user);
  if (user) {
    // User is logged in
    this.loggedInUser = user;
  } else {
    // User is not logged in or has logged out
    this.loggedInUser = null;
  }
});