Open Source Library for Angular Web Apps to integrate a material user interface for firebase authentication
npm install ngx-auth-firebaseui-folio
src="https://cdn.jsdelivr.net/gh/anthonynahas/ngx-auth-firebaseui@master/demo/src/assets/logo.svg">


















src="ngx-auth-firebaseui-logo.png">
Angular UI component for firebase authentication.
This library is an angular module (including angular components and services) that allows to authenticate
your users with your firebase project. NgxAuthFirebseUI is compatible with
angular material and angular flexLayout.
If you prefer to develop with bootstrap rather than with material design, please check this project @firebaseui/ng-bootstrap
any question or suggestion ? Please do not hesitate to contact us!If you like this project, support ngx-auth-firebaseui
by starring :star: and sharing it :loudspeaker:
| Features | ngx-auth-firebaseui | firebaseui |
| -----------------------------------------------|:-------------:| :-------------------: |
| Sign Up | :heavy_check_mark: | :heavy_check_mark: |
| Sign In | :heavy_check_mark: | :heavy_check_mark: |
| Sign In Anonymously | :heavy_check_mark: | :heavy_check_mark: |
| Sign In with Google | :heavy_check_mark: | :heavy_check_mark: |
| Sign In with Facebook | :heavy_check_mark: | :heavy_check_mark: |
| Sign In with Twitter | :heavy_check_mark: | :heavy_check_mark: |
| Sign In with Github | :heavy_check_mark: | :heavy_check_mark: |
| Sign In with Microsoft | :heavy_check_mark: | :heavy_check_mark: |
| Sign In with Yahoo | :heavy_check_mark: | :heavy_check_mark: |
| Sign In with Phonenumber | :x: | :heavy_check_mark: |
| Sign out | :heavy_check_mark: | :x: |
| Sign in/up progress indicator | :heavy_check_mark: | :x: |
| Password Strength indicator | :heavy_check_mark: | :x: |
| Forgot/Reset Password | :heavy_check_mark: | :x: |
| Password Strength Meter | :heavy_check_mark: | :x: |
| Delete account | :heavy_check_mark: | :x: |
| Login Authentication Guard | :heavy_check_mark: | :x: |
| User Profile | :heavy_check_mark: | :x: |
| Check whether user's email is verified | :heavy_check_mark: | :x: |
| Edit user's display name (incl. validation) | :heavy_check_mark: | :x: |
| Edit user's email (incl. validation) | :heavy_check_mark: | :x: |
| Edit user's phone number (incl. validation) | :heavy_check_mark: | :x: |
| Configure your favorite auth provider in runtime| :heavy_check_mark: | :x: |
| Sync user'auth with Firestore read more | :heavy_check_mark: | :x: |
| Angular v2-8 friendly | :heavy_check_mark: | :x: |
| Internationalization (i18n) | :heavy_check_mark: | :heavy_check_mark: |
| Ionic/cordova support | :soon: @firebaseui/ionic-auth | :x: |
| Real time form validation | :heavy_check_mark: | :x: |
| Easy to integrate | :heavy_check_mark: | :x: |
| Support Server Side Rendering | :heavy_check_mark: | :x: |
| Support SPA without further config | :heavy_check_mark: | :x: |
| Support Safari private browsing | :heavy_check_mark: | :interrobang: |
| AWESOME | :heavy_check_mark: | :interrobang: |
any important event occurred.ngx-auth-firebaseui-user used for the authentication process used to display only buttons for providers like google, facebook, twitter, github, microsoft and yahoo used to display/edit the data of the current authenticated user in form of a material card used to display/edit the data of the current authenticated user in the toolbarnumber :soon:number- angular material theme
- angular material icons
- angular cdk - v8.x
- angular material - v8.x
- angular forms - v8.x
- angular animations - v8.x
- angular flex-layout v8.0.0-beta.26
- @angular/fire - v5.2.x
- firebase - v6.x
the full tutorial guide can be found here
take a look at live example with firestore's synchronization here
---
v8
src="assets/v3.0.0/demo.png">
in combination with ngx-auth-firebaseui-user
src="assets/v3.0.0/demo_full.png">
v7
src="assets/v1.0.0/png/signin.png">
- Sign up - registration
#### before
src="assets/v1.0.0/png/register_filled_2.png">
#### after
src="assets/v1.0.0/png/registered_confirm.png">
#### demo outlook
src="assets/v1.0.0/png/registration_full.png">
src="assets/v1.0.0/png/register_validation_errors.png">
#### row layout
Please note: when the view port is getting too small, the layout will be
automatically change to column
src="assets/v3.0.0/providers_column.png">
#### column layout
src="assets/v3.0.0/providers_rows.png">
#### when logged out
src="assets/v1.0.0/png/user_logged_out.png">
#### when logged in
src="assets/v1.0.0/png/user.png">
#### in edit mode
src="assets/v1.0.0/png/user_edit_mode.png">
src="assets/v1.0.0/png/signin_mobile.png">
- Before
src="assets/v1.0.0/png/forgot_password0.png">
- After
src="assets/v1.0.0/png/forgot_password_sent.png">
src="assets/v2.7.0/2.gif">
---
``json`
"peerDependencies": {
"@angular/core": "^8.x",
"@angular/animations": "^8.x",
"@angular/cdk": "^8.x",
"@angular/flex-layout": "^8.0.0-beta.26",
"@angular/forms": "^8.x",
"@angular/material": "^8.x",
"@angular/fire": "5.2.x",
"firebase": "6.x",
}
#### NOTE:
If you are still running angular v5, please consider to user ngx-auth-firebaseui v0.x
v1.x should be used with angular v7 projects
v3.x should be used with angular v8 projects
---
the @angular-material-extensions/password-strength is used
to indicate how secure is the provided password when registering a new firebase user e.g:
src="assets/v0.7.1/features/password/ngx-material-password-strength.gif">
If Angular Material Design is not setup, just run ng add @angular/material learn more
Now add the library via the angular schematics`shell`
ng add ngx-auth-firebaseui
- :heavy_check_mark: peer dependencies will be automatically added the package.json and installed
- :heavy_check_mark: ngx-auth-firebaseui 's module will be automatically imported to the root module (just replace PUT_YOUR_FIREBASE_API_KEY_HERE with your firebase api key)ngx-auth-firebaseui
- :heavy_check_mark: 's assets will be automatically added the angular.json file
Install above dependencies via npm.
Now install ngx-auth-firebaseui via:`shell`
npm install --save ngx-auth-firebaseui
`bash`
npm i -s @angular/material @angular/cdk @angular/flex-layout @angular/forms @angular/animations
Firebase deps
`bash`
npm i -s firebase @angular/fire
-> continue by following the instructions here
Once installed you need to import the main module:
`js`
import { NgxAuthFirebaseUIModule } from 'ngx-auth-firebaseui-folio'; NgxAuthFirebaseUIModule .forRoot()
The only remaining part is to list the imported module in your application module. The exact method will be slightly
different for the root (top-level) module for which you should end up with the code similar to (notice ):
and then from your Angular AppModule:
`typescript
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
// Import your library
import { NgxAuthFirebaseUIModule } from 'ngx-auth-firebaseui-folio';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
// Specify the ngx-auth-firebaseui library as an import
NgxAuthFirebaseUIModule.forRoot({
apiKey: 'your-firebase-apiKey',
authDomain: 'your-firebase-authDomain',
databaseURL: 'your-firebase-databaseURL',
projectId: 'your-firebase-projectId',
storageBucket: 'your-firebase-storageBucket',
messagingSenderId: 'your-firebase-messagingSenderId'
}),
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
`
Other modules in your application can simply import NgxAuthFirebaseUIModule :
`js
import { NgxAuthFirebaseUIModule } from 'ngx-auth-firebaseui-folio';
@NgModule({
declarations: [OtherComponent, ...],
imports: [NgxAuthFirebaseUIModule, ...],
})
export class OtherModule {
}
`
---
##### SystemJS
>Note:If you are using SystemJS, you should adjust your configuration to point to the UMD bundle.map
In your systemjs config file, needs to tell the System loader where to look for ngx-auth-firebaseui:`js`
map: {
'ngx-auth-firebaseui': 'node_modules/ngx-auth-firebaseui/bundles/ngx-auth-firebaseui.umd.js',
}
`typescript
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
// Import your library
import { NgxAuthFirebaseUIModule } from 'ngx-auth-firebaseui-folio';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
// Specify the ngx-auth-firebaseui library as an import
NgxAuthFirebaseUIModule.forRoot(
{
apiKey: 'your-firebase-apiKey',
authDomain: 'your-firebase-authDomain',
databaseURL: 'your-firebase-databaseURL',
projectId: 'your-firebase-projectId',
storageBucket: 'your-firebase-storageBucket',
messagingSenderId: 'your-firebase-messagingSenderId'
},
() => 'your_app_name_factory',
{
enableFirestoreSync: true, // enable/disable autosync users with firestore
toastMessageOnAuthSuccess: false, // whether to open/show a snackbar message on auth success - default : true
toastMessageOnAuthError: false, // whether to open/show a snackbar message on auth error - default : true
authGuardFallbackURL: '/loggedout', // url for unauthenticated users - to use in combination with canActivate feature on a route
authGuardLoggedInURL: '/loggedin', // url for authenticated users - to use in combination with canActivate feature on a route
}),
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
`
----
---
Once the library is imported, you can use its components, directives and pipes in your Angular application:
`html
``
ortypescript
@Component({
selector: 'app',
template:
})
class AppComponent {
printUser(event) {
console.log(event);
}
printError(event) {
console.error(event);
}
}
`
#### Result:
src="assets/v0.7.1/features/overview/overview.png">
html
`$3
`html
`#### Result:
src="assets/v0.7.1/features/user/user_verified_2.png">
$3
`html
`
src="assets/v3.0.0/avatar.png">
API
$3
| option | bind | type | default | description |
|:---------------------|:------:|:------:|:------------:|:-------------------------------------------------------------------------------------------------|
| providers |
Input() | string[] | ['all'] or [AuthProvider.All] | choose your favorite authentication provider: google | facebook | twitter | github
| appearance | Input() | MatFormFieldAppearance | standard | the appearance of the mat-form-field #'legacy' | 'standard' | 'fill' | 'outline'
| tabIndex | Input() | number | null; | 0 | the selected tab - either sign in or register
| registrationEnabled | Input() | boolean | true | whether the user is able to register a new account
| resetPasswordEnabled | Input() | boolean | true | whether the user is able to reset his account password
| guestEnabled | Input() | boolean | true | whether the user can sign in and continue as guest
| tosUrl | Input() | string | - | the url of term of services
| privacyPolicyUrl | Input() | string | - | the url of the private privacy
| goBackURL | Input() | string | - | the url to redirect to after creating a new user and clicking the go back button - the button is only available when the input is provided
| messageOnAuthSuccess | Input() | string | see the code -> | the message of the snackbar when the authentication process was successful
| messageOnAuthError | Input() | string | see the code -> | the message of the snackbar when the authentication process has failed
| onSuccess | Output() | any | - | this will be fired when an authentication process was success. The authenticated user is emitted!
| onError | Output() | any | - | this event will be fired when an error occurred during the authentication process! An error message is emitted!
| selectedTabChange | Output() | MatTabChangeEvent | - | output event is emitted when the active tab changes (signin, register and reset password tab)
| enableLengthRule | Input() | boolean | true | whether to validate the length of the password
| enableLowerCaseLetterRule | Input() | boolean | true | whether a lowercase letter is optional
| enableUpperCaseLetterRule | Input() | boolean | true | whether a uppercase letter is optional
| enableDigitRule | Input() | boolean | true | whether a digit char is optional
| enableSpecialCharRule | Input() | boolean | true | whether a special char is optional
| min | Input() | number | 8 | the minimum length of the password
| max | Input() | number | 30 | the maximum length of the password
| onStrengthChanged | Output() | number | - | emits the strength of the provided password in % e.g: 20%, 40%, 60%, 80% or 100%if you prefer to customize the text of this component, check these inputs here that have been used for translations
PS: if either
tosUrl or privacyPolicyUrl are provided, the user will be asked to check and accepts tos and pp before registering a new account or sign in in anonymously``html`
(onError)="printError($event)">
Result:
src="assets/v1.1.0/guest_disabled.png">
`typescript
import {OnInit} from '@angular/core';
import {AuthProvider} from 'ngx-auth-firebaseui-folio';
export class ExampleComponent implements OnInit {
providers = AuthProvider;
ngOnInit() {
}
}
`
in your template -->
`html`
(onSuccess)="printUser($event)"
(onError)="printError()">
or
`html`
(onSuccess)="printUser($event)"
(onError)="printError()">
take a look at the full documentation here
| option | bind | type | default | description |
|:---------------------|:------:|:------:|:------------:|:-------------------------------------------------------------------------------------------------|
| layout | Input() | string | row | set the layout of the providers buttons options: 'column' or 'row'Input()
| theme | | string | default | set the theme of the providers buttons options: '', 'classic', 'stroked', 'fab', 'mini-fab', 'raised',Output()
| onSuccess | | any | - | this will be fired when an authentication process was success. The authenticated user is emitted!Output()
| onError | | any | - | this event will be fired when an error occurred during the authentication process! An error message is emitted!
e.g: in template:
`html`
in your component:
`typescript
import {Component} from '@angular/core';
import {AuthProvider, Theme} from 'ngx-auth-firebaseui-folio';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
themes = Theme;
}
`
src="assets/v3.0.0/providers.png">
| option | bind | type | default | description |
|:---------------------|:------:|:------:|:------------:|:-------------------------------------------------------------------------------------------------|
| editMode | Input() | boolean | false | whether the use is in edit modeInput()
| canLogout | | boolean | true | whether to render the logout buttonInput()
| canDeleteAccount | | boolean | true | whether to render the delete account buttonInput()
| appearance | | MatFormFieldAppearance | - | the style of the mat-input-formOutput()
| onSignOut | | void | - | this will be fired when the user signs outOutput()
| onAccountDeleted | | void | - | this will be fired when the user deletes his account
| option | bind | type | default | description |
|:---------------------|:------:|:------:|:------------:|:-------------------------------------------------------------------------------------------------|
| canLogout | Input() | boolean | true | whether to render the logout buttonInput()
| links | | LinkMenuItem[] | - | additional routes and links to add to the componentOutput()
| onSignOut | | void | - | this will be fired when the user signs out
If you want to prevent a route to be accessed from non authorized users, you can
use a built in LoggedInGuard angular router guard.
1. enter the fallback url in the NgxAuthFirebaseUIConfig under authGuardFallbackURLNgxAuthFirebaseUIConfig
2. enter the logged in url in the under authGuardLoggedInURL
`ts
import {NgxAuthFirebaseUIModule} from 'ngx-auth-firebaseui-folio';
NgxAuthFirebaseUIModule.forRoot(firebaseKey, firebaseAppNameFactory,
{
authGuardFallbackURL: 'examples/logged-out',
authGuardLoggedInURL: 'examples/logged-in',
}),
`
if the user is logged in, he will be redirected to examples/logged-in route (per example), examples/logged-out
otherwise he will be redirected to the route
3. import the LoggedInGuard in your router module
`ts
import {NgModule} from '@angular/core';
import {Routes, RouterModule} from '@angular/router';
import {LoggedInGuard} from 'ngx-auth-firebaseui-folio';
const routes: Routes = [
{
path: '',
redirectTo: 'home',
pathMatch: 'full'
},
{
path: 'secured',
loadChildren: 'app/secured/secured.module#SecuredModule',
canActivate: [LoggedInGuard]
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule {
}
``
---
---
This project is supported by jetbrains with 1 ALL PRODUCTS PACK OS LICENSE incl. webstorm
---
Copyright (c) 2018 Anthony Nahas. Licensed under the MIT License (MIT)