File

src/module/components/ngx-auth-firebaseui/auth.component.ts

Implements

OnInit AfterViewInit OnChanges OnDestroy

Metadata

changeDetection ChangeDetectionStrategy.OnPush
selector ngx-auth-firebaseui
styleUrls auth.component.scss
templateUrl auth.component.html

Index

Properties
Methods
Inputs
Outputs
Accessors

Constructor

constructor(platformId: Object, auth: AngularFireAuth, authProcess: AuthProcessService, dialog: MatDialog, config: NgxAuthFirebaseUIConfig, _activatedRoute: ActivatedRoute, _cdr: ChangeDetectorRef)
Parameters :
Name Type Optional
platformId Object No
auth AngularFireAuth No
authProcess AuthProcessService No
dialog MatDialog No
config NgxAuthFirebaseUIConfig No
_activatedRoute ActivatedRoute No
_cdr ChangeDetectorRef No

Inputs

appearance
Type : MatFormFieldAppearance
customValidator
Type : RegExp
emailConfirmationText
Default value : `A confirmation e-mail has been sent to you. Check your inbox and click on the link "Confirm my e-mail" to confirm your e-mail address.`
emailConfirmationTitle
Default value : 'Confirm your e-mail address!'
emailErrorPatternText
Default value : 'Please enter a valid e-mail address'
emailErrorRequiredText
Default value : 'E-mail is required'
emailText
Default value : 'E-mail'
enableDigitRule
Default value : true
enableLengthRule
Default value : true
enableLowerCaseLetterRule
Default value : true
enableSpecialCharRule
Default value : true
enableUpperCaseLetterRule
Default value : true
forgotPasswordButtonText
Default value : 'Forgot Password ?'
goBackURL
Type : string
guestButtonText
Default value : 'continue as guest'
guestEnabled
Default value : true
loginButtonText
Default value : 'Log In'
max
Type : number
messageOnAuthError
Type : messageOnAuthErrorType
messageOnAuthSuccess
Type : string
messageOnEmailConfirmationSuccess
Type : string
min
Type : number
nameErrorMaxLengthText
Default value : 'The name is too long!'
nameErrorMinLengthText
Default value : 'The name is too short!'
nameErrorRequiredText
Default value : 'Name is required'
nameText
Default value : 'Name'
passwordErrorMaxLengthText
Default value : 'The password is too long!'
passwordErrorMinLengthText
Default value : 'The password is too short!'
passwordErrorRequiredText
Default value : 'Password is required'
passwordText
Default value : 'Password'
privacyPolicyUrl
Type : string
providers
Type : AuthProvider[] | AuthProvider
Default value : AuthProvider.ALL
providersTheme
Type : Theme
registerButtonText
Default value : 'Register'
registerCardTitleText
Default value : 'Registration'
registerTabText
Default value : 'Register'
registrationEnabled
Default value : true
resetPasswordActionButtonText
Default value : 'Reset'
resetPasswordEnabled
Default value : true
resetPasswordErrorPatternText
Default value : 'Please enter a valid e-mail address'
resetPasswordErrorRequiredText
Default value : 'E-mail is required to reset the password!'
resetPasswordInputText
Default value : 'Reset e-mail address to password'
resetPasswordInstructionsText
Default value : 'Reset requested. Check your e-mail instructions.'
resetPasswordTabText
Default value : 'Reset e-mail address to password'
sendNewVerificationEmailText
Type : string
signInCardTitleText
Default value : 'Signing in'
signInTabText
Default value : 'Sign in'
signOutText
Type : string
tabIndex
Type : number | null
tosUrl
Type : string
verifyEmailConfirmationText
Type : string
verifyEmailGoBackText
Type : string
verifyEmailTemplate
Type : TemplateRef<any>
verifyEmailTitleText
Type : string

Outputs

onError
Type : any
onStrengthChanged
Type : EventEmitter<number>
onSuccess
Type : any
selectedTabChange
Type : EventEmitter<MatTabChangeEvent>

Methods

Private _afterSignUpMiddleware
_afterSignUpMiddleware(authProvider?: AuthProvider)
Parameters :
Name Type Optional
authProvider AuthProvider Yes
Returns : any
Private _initResetPasswordFormGroupBuilder
_initResetPasswordFormGroupBuilder()
Returns : void
Private _initSignInFormGroupBuilder
_initSignInFormGroupBuilder()
Returns : void
Private _initSignUpFormGroupBuilder
_initSignUpFormGroupBuilder()
Returns : void
Private chooseBackUrl
chooseBackUrl()
Returns : any
createForgotPasswordTab
createForgotPasswordTab()
Returns : void
ngAfterViewInit
ngAfterViewInit()
Returns : void
ngOnChanges
ngOnChanges(changes: SimpleChanges)
Parameters :
Name Type Optional
changes SimpleChanges No
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
Public ngOnInit
ngOnInit()
Returns : void
onTabChange
onTabChange(event: MatTabChangeEvent)
Parameters :
Name Type Optional
event MatTabChangeEvent No
Returns : void
processLegalSignUP
processLegalSignUP(authProvider?: AuthProvider)
Parameters :
Name Type Optional
authProvider AuthProvider Yes
Returns : void
resetPassword
resetPassword()
Returns : void
Async signIn
signIn()
Returns : any
Async signOut
signOut()
Returns : any
Async signUp
signUp()
Returns : {}
Async signUpAnonymously
signUpAnonymously()
Returns : any
updateAuthSnackbarMessages
updateAuthSnackbarMessages()
Returns : void

Properties

Public auth
Type : AngularFireAuth
authenticationError
Default value : false
Public authProcess
Type : AuthProcessService
authProvider
Default value : AuthProvider
authProviders
Default value : AuthProvider
Public config
Type : NgxAuthFirebaseUIConfig
Decorators :
@Inject(undefined)
Public dialog
Type : MatDialog
dialogRef
Type : MatDialogRef<LegalityDialogComponent>
isLoading
Type : boolean
matTabGroup
Type : MatTabGroup
Decorators :
@ViewChild(MatTabGroup, {static: false})
onErrorSubscription
Type : Subscription
passReset
Default value : false
passwordResetWished
Type : boolean
passwordStrength
Type : MatPasswordStrengthComponent
Decorators :
@ViewChild(MatPasswordStrengthComponent, {static: false})
resetPasswordEmailFormControl
Type : AbstractControl
Public resetPasswordFormGroup
Type : FormGroup
sigInPasswordFormControl
Type : AbstractControl
signInEmailFormControl
Type : AbstractControl
Public signInFormGroup
Type : FormGroup
Public signUpFormGroup
Type : FormGroup
sigUpEmailFormControl
Type : AbstractControl
sigUpNameFormControl
Type : AbstractControl
sigUpPasswordConfirmationFormControl
Type : AbstractControl
sigUpPasswordFormControl
Type : AbstractControl

Accessors

color
getcolor()
import {isPlatformBrowser} from '@angular/common';
import {
  AfterViewInit,
  ChangeDetectionStrategy,
  ChangeDetectorRef,
  Component,
  EventEmitter,
  forwardRef,
  Inject,
  Input,
  OnChanges,
  OnDestroy,
  OnInit,
  Output,
  PLATFORM_ID,
  SimpleChanges,
  TemplateRef,
  ViewChild
} from '@angular/core';
import {AngularFireAuth} from '@angular/fire/auth';
import {AbstractControl, FormControl, FormGroup, Validators} from '@angular/forms';
import {MatDialog, MatDialogRef, MatFormFieldAppearance, MatTabChangeEvent, MatTabGroup, ThemePalette} from '@angular/material';
import {ActivatedRoute} from '@angular/router';
import {Subscription} from 'rxjs/internal/Subscription';
import {LegalityDialogComponent} from '../../components/legality-dialog/legality-dialog.component';
import {LegalityDialogParams, LegalityDialogResult} from '../../interfaces/legality.dialog.intreface';
import {NgxAuthFirebaseUIConfig, NgxAuthFirebaseUIConfigToken} from '../../ngx-auth-firebase-u-i.module';
import {AuthProcessService, AuthProvider, messageOnAuthErrorType} from '../../services/auth-process.service';
import {Theme} from '../providers/auth.providers.component';
import {MatPasswordStrengthComponent} from '@angular-material-extensions/password-strength';
import {NgxAuthFirebaseuiAnimations} from '../../animations';


export const EMAIL_REGEX = new RegExp(['^(([^<>()[\\]\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\.,;:\\s@\"]+)*)',
  '|(".+"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.',
  '[0-9]{1,3}\])|(([a-zA-Z\\-0-9]+\\.)+',
  '[a-zA-Z]{2,}))$'].join(''));

export const PHONE_NUMBER_REGEX = new RegExp(['^[+]{0,1}[(]{0,1}[0-9]{1,4}[)]{0,1}[-\\s\\.]{0,1}[(]{0,1}[0-9]{1,4}[)]{0,1}[-\\s\\./0-9]{4,12}$'].join(''));

@Component({
  selector: 'ngx-auth-firebaseui',
  templateUrl: 'auth.component.html',
  styleUrls: ['auth.component.scss'],
  animations: NgxAuthFirebaseuiAnimations,
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class AuthComponent implements OnInit, AfterViewInit, OnChanges, OnDestroy {

  @ViewChild(MatTabGroup, {static: false}) matTabGroup: MatTabGroup;
  @ViewChild(MatPasswordStrengthComponent, {static: false}) passwordStrength: MatPasswordStrengthComponent;

  isLoading: boolean;

  @Input() providers: AuthProvider[] | AuthProvider = AuthProvider.ALL; //  google, facebook, twitter, github as array or all as one single string
  @Input() providersTheme: Theme; // Classic, Stroked, etc.

  @Input() appearance: MatFormFieldAppearance;
  @Input() tabIndex: number | null;
  @Input() registrationEnabled = true;
  @Input() resetPasswordEnabled = true;
  @Input() guestEnabled = true;
  @Input() tosUrl: string;
  @Input() privacyPolicyUrl: string;
  @Input() goBackURL: string;
  @Input() messageOnAuthSuccess: string;
  @Input() messageOnAuthError: messageOnAuthErrorType;
  @Input() messageOnEmailConfirmationSuccess: string;

  // Events
  @Output() onSuccess: any;
  @Output() onError: any;
  @Output() selectedTabChange: EventEmitter<MatTabChangeEvent> = new EventEmitter();

  // Password strength api
  @Input() enableLengthRule = true;
  @Input() enableLowerCaseLetterRule = true;
  @Input() enableUpperCaseLetterRule = true;
  @Input() enableDigitRule = true;
  @Input() enableSpecialCharRule = true;
  @Input() min: number;
  @Input() max: number;
  @Input() customValidator: RegExp;
  @Output() onStrengthChanged: EventEmitter<number> = new EventEmitter();

  // Verify email template to use in place of default template.
  // See email-confirmation component
  @Input() verifyEmailTemplate: TemplateRef<any>;

  // i18n translations to use in default template for email verification.
  // See email-confirmation component
  @Input() verifyEmailTitleText: string;
  @Input() verifyEmailConfirmationText: string;
  @Input() verifyEmailGoBackText: string;
  @Input() sendNewVerificationEmailText: string;
  @Input() signOutText: string;

  // Customize the text
  // Reset Password Tab
  @Input() resetPasswordTabText = 'Reset e-mail address to password';
  @Input() resetPasswordInputText = 'Reset e-mail address to password';
  @Input() resetPasswordErrorRequiredText = 'E-mail is required to reset the password!';
  @Input() resetPasswordErrorPatternText = 'Please enter a valid e-mail address';
  @Input() resetPasswordActionButtonText = 'Reset';
  @Input() resetPasswordInstructionsText = 'Reset requested. Check your e-mail instructions.';

  // SignIn Tab
  @Input() signInTabText = 'Sign in';
  @Input() signInCardTitleText = 'Signing in';
  @Input() loginButtonText = 'Log In';
  @Input() forgotPasswordButtonText = 'Forgot Password ?';

  // Common
  @Input() nameText = 'Name';
  @Input() nameErrorRequiredText = 'Name is required';
  @Input() nameErrorMinLengthText = 'The name is too short!';
  @Input() nameErrorMaxLengthText = 'The name is too long!';

  @Input() emailText = 'E-mail';
  @Input() emailErrorRequiredText = 'E-mail is required';
  @Input() emailErrorPatternText = 'Please enter a valid e-mail address';

  @Input() passwordText = 'Password';
  @Input() passwordErrorRequiredText = 'Password is required';
  @Input() passwordErrorMinLengthText = 'The password is too short!';
  @Input() passwordErrorMaxLengthText = 'The password is too long!';

  // Register Tab
  @Input() registerTabText = 'Register';
  @Input() registerCardTitleText = 'Registration';
  @Input() registerButtonText = 'Register';
  @Input() guestButtonText = 'continue as guest';

  // email confirmation component
  @Input() emailConfirmationTitle = 'Confirm your e-mail address!';
  @Input() emailConfirmationText = `A confirmation e-mail has been sent to you. Check your inbox and click on the link "Confirm my e-mail" to confirm your e-mail address.`;

  authProvider = AuthProvider;
  passwordResetWished: boolean;

  public signInFormGroup: FormGroup;
  public signUpFormGroup: FormGroup;
  public resetPasswordFormGroup: FormGroup;

  onErrorSubscription: Subscription;
  authenticationError = false;

  passReset = false;
  dialogRef: MatDialogRef<LegalityDialogComponent>;

  authProviders = AuthProvider;

  signInEmailFormControl: AbstractControl;
  sigInPasswordFormControl: AbstractControl;

  sigUpNameFormControl: AbstractControl;
  sigUpEmailFormControl: AbstractControl;
  sigUpPasswordFormControl: AbstractControl;
  sigUpPasswordConfirmationFormControl: AbstractControl;
  resetPasswordEmailFormControl: AbstractControl;

  constructor(
    @Inject(PLATFORM_ID) private platformId: Object,
    public auth: AngularFireAuth,
    public authProcess: AuthProcessService,
    public dialog: MatDialog,
    @Inject(forwardRef(() => NgxAuthFirebaseUIConfigToken)) public config: NgxAuthFirebaseUIConfig,
    private _activatedRoute: ActivatedRoute,
    private _cdr: ChangeDetectorRef
  ) {
    this.onSuccess = authProcess.onSuccessEmitter;
    this.onError = authProcess.onErrorEmitter;
  }

  public ngOnInit(): void {
    if (isPlatformBrowser(this.platformId)) {
      this.onErrorSubscription = this.onError.subscribe(() => this.authenticationError = true);
    }
    this.min = this.min != null ? Math.max(this.min, this.config.passwordMinLength) : this.config.passwordMinLength;
    this.max = this.max != null ? Math.min(this.max, this.config.passwordMaxLength) : this.config.passwordMaxLength;

    this.goBackURL = this.chooseBackUrl();

    this.updateAuthSnackbarMessages();
    // auth form's initialization
    this._initSignInFormGroupBuilder();
    this._initSignUpFormGroupBuilder();
    this._initResetPasswordFormGroupBuilder();
  }

  ngAfterViewInit(): void {
    if (this.passwordStrength) {
      this.passwordStrength.onStrengthChanged.subscribe((strength: number) => {
        this.onStrengthChanged.emit(strength);
      });
    }
  }

  ngOnChanges(changes: SimpleChanges): void {
    if (changes.messageOnAuthSuccess || changes.messageOnAuthError) {
      this.updateAuthSnackbarMessages();
    }
    if (changes.min) {
      this.min = this.min != null ? Math.max(this.min, this.config.passwordMinLength) : this.config.passwordMinLength;
    }
    if (changes.max) {
      this.max = this.max != null ? Math.min(this.max, this.config.passwordMaxLength) : this.config.passwordMaxLength;
    }
    if (changes.goBackURL) {
      this.goBackURL = this.chooseBackUrl();
    }
  }

  ngOnDestroy(): void {
    if (this.onErrorSubscription) {
      this.onErrorSubscription.unsubscribe();
    }
  }

  onTabChange(event: MatTabChangeEvent) {
    this.selectedTabChange.emit(event);
    this.tabIndex = event.index;
  }

  async signOut() {
    try {
      this.isLoading = true;
      this._cdr.markForCheck();
      await this.authProcess.signOut();
    } finally {
      this.isLoading = false;
      this._cdr.markForCheck();
    }
  }

  async signIn() {
    if (!this.signInFormGroup.valid) {
      return;
    }
    try {
      this.isLoading = true;
      this._cdr.markForCheck();
      await this.authProcess.signInWith(this.authProviders.EmailAndPassword, {
        email: this.signInFormGroup.value.email,
        password: this.signInFormGroup.value.password
      });
    } finally {
      this.isLoading = false;
      this._cdr.markForCheck();
    }
  }

  get color(): string | ThemePalette {
    return this.authenticationError ? 'warn' : 'primary';
  }

  updateAuthSnackbarMessages(): void {
    this.authProcess.messageOnAuthSuccess = this.messageOnAuthSuccess;
    this.authProcess.messageOnAuthError = this.messageOnAuthError;
  }

  createForgotPasswordTab() {
    this.passwordResetWished = true;
    this.tabIndex = 2;
    this._cdr.markForCheck();
  }

  processLegalSignUP(authProvider?: AuthProvider) {
    if (this.tosUrl || this.privacyPolicyUrl) {
      const params: LegalityDialogParams = {
        tosUrl: this.tosUrl,
        privacyPolicyUrl: this.privacyPolicyUrl,
        authProvider: authProvider
      };

      this.dialogRef = this.dialog.open(LegalityDialogComponent, {data: params});
      this.dialogRef.afterClosed().subscribe((result: LegalityDialogResult) => {
        if (result && result.checked) {
          this._afterSignUpMiddleware(result.authProvider).then(() => this.signUpFormGroup.reset());
        }
        this.dialogRef = null;
      });
    } else {
      this._afterSignUpMiddleware(authProvider).then(() => this.signUpFormGroup.reset());
    }
  }

  async signUp() {
    try {
      this.isLoading = true;
      this._cdr.markForCheck();
      return await this.authProcess.signUp(
        this.signUpFormGroup.value.name,
        {
          email: this.signUpFormGroup.value.email,
          password: this.signUpFormGroup.value.password
        }
      );
    } finally {
      this.isLoading = false;
      this._cdr.markForCheck();
    }
  }

  async signUpAnonymously() {
    try {
      this.isLoading = true;
      this._cdr.markForCheck();
      await this.authProcess.signInWith(this.authProvider.ANONYMOUS);
    } finally {
      this.isLoading = false;
      this._cdr.markForCheck();
    }
  }


  resetPassword() {
    this.authProcess.resetPassword(this.resetPasswordEmailFormControl.value)
      .then(() => {
        this.passReset = true;
        // this.tabIndex = 2;
        this._cdr.markForCheck();
      });
  }

  private chooseBackUrl() {
    return this._activatedRoute.snapshot.queryParams['redirectUrl'] || this.goBackURL || '/';
  }

  private _initSignInFormGroupBuilder() {
    this.signInFormGroup = new FormGroup({});
    this.signInFormGroup.registerControl('email', this.signInEmailFormControl = new FormControl('',
      [
        Validators.required,
        Validators.pattern(EMAIL_REGEX)
      ]));
    this.signInFormGroup.registerControl('password', this.sigInPasswordFormControl = new FormControl('',
      [
        Validators.required,
        Validators.minLength(this.min),
        Validators.maxLength(this.max)
      ]));
  }

  private _initSignUpFormGroupBuilder() {
    this.signUpFormGroup = new FormGroup({
      name: this.sigUpNameFormControl = new FormControl('',
        [
          Validators.required,
          Validators.minLength(this.config.nameMinLength),
          Validators.maxLength(this.config.nameMaxLength)
        ]),
      email: this.sigUpEmailFormControl = new FormControl('',
        [
          Validators.required,
          Validators.pattern(EMAIL_REGEX)
        ]),
      password: this.sigUpPasswordFormControl = new FormControl('',
        [
          Validators.required,
          Validators.minLength(this.min),
          Validators.maxLength(this.max),
        ])
    });
  }

  private _initResetPasswordFormGroupBuilder() {
    this.resetPasswordFormGroup = new FormGroup({
      email: this.resetPasswordEmailFormControl = new FormControl('',
        [
          Validators.required,
          Validators.pattern(EMAIL_REGEX)
        ])
    });
  }

  private _afterSignUpMiddleware(authProvider?: AuthProvider) {
    if (authProvider === this.authProvider.ANONYMOUS) {
      return this.signUpAnonymously();
    }
    return this.signUp();
  }

}
<ng-container *ngIf="authProcess.user$ | async as user; else showForm">

  <!-- This component will be shown when:
    - we just sent a verification mail (notably after sign up)
    - we arrived from the guard after trying to access a protected route even though we are connected
  -->
  <div *ngIf="(config.guardProtectedRoutesUntilEmailIsVerified && !user.emailVerified) || (authProcess.emailConfirmationSent && !user.emailVerified); else signedInUser"
       fxLayout="row" fxLayoutAlign="center center">
      <ngx-auth-firebaseui-email-confirmation
        [template]="verifyEmailTemplate"
        [email]="user.email"
        [goBackURL]="goBackURL"
        [verifyEmailTitleText]="verifyEmailTitleText"
        [verifyEmailConfirmationText]="verifyEmailConfirmationText"
        [verifyEmailGoBackText]="verifyEmailGoBackText"
        [sendNewVerificationEmailText]="sendNewVerificationEmailText"
        [signOutText]="signOutText"
        [messageOnEmailConfirmationSuccess]="messageOnEmailConfirmationSuccess"
        (signOut)="signOut()">
    </ngx-auth-firebaseui-email-confirmation>
  </div>

  <ng-template #signedInUser>
      <div class="signed-in-container" fxLayout="column" fxLayoutAlign="center center">
        <img class="account-circle" *ngIf="user.photoURL; else noPhoto" [src]="user.photoURL">
        <ng-template #noPhoto><mat-icon class="account-circle">account_circle</mat-icon></ng-template>
        <div class="user-display-name mat-title">{{ user.displayName }}</div>
        <div class="user-email mat-body-2">{{ user.email }}</div>
        <div class="actions">
          <mat-progress-bar *ngIf="isLoading" mode="indeterminate"></mat-progress-bar>
          <a mat-stroked-button class="go-back-button action-button" color="primary" [routerLink]="goBackURL">{{ verifyEmailGoBackText }}</a>
          <button mat-stroked-button class="sign-out-button action-button" color="warn" (click)="signOut()">{{ signOutText }}</button>
        </div>
      </div>
  </ng-template>

</ng-container>

<ng-template #showForm>
  <mat-tab-group [color]="color" [selectedIndex]="tabIndex" (selectedTabChange)="onTabChange($event)">
    <!--Sign in tab-->
    <mat-tab [label]="signInTabText">
      <mat-card>
        <mat-card-title>{{signInCardTitleText}}</mat-card-title>
        <mat-card-content>
          <form  [@animateStagger]="{ value: '50' }"
                 [formGroup]="signInFormGroup"
                (ngSubmit)="signIn()">
            <div fxLayout="column" fxLayoutAlign="center">
              <mat-form-field [@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
                              [appearance]="appearance">
                <mat-label>{{emailText}}</mat-label>
                <input matInput
                      formControlName="email"
                      required>
                <mat-icon matSuffix [color]="color">email</mat-icon>
                <mat-error *ngIf="signInEmailFormControl.hasError('required')">
                  {{emailErrorRequiredText}}
                </mat-error>
                <mat-error *ngIf="signInEmailFormControl.hasError('pattern')">
                  {{emailErrorPatternText}}
                </mat-error>
              </mat-form-field>

              <mat-form-field [@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
                            [appearance]="appearance">
                <mat-label>{{passwordText}}</mat-label>
                <input matInput [type]="togglePass.type" [minlength]="min" [maxlength]="max" formControlName="password"
                      required/>
                <mat-pass-toggle-visibility #togglePass matSuffix></mat-pass-toggle-visibility>
                <mat-icon matSuffix [color]="color">lock</mat-icon>
                <mat-hint align="end" aria-live="polite"> {{ signInFormGroup.value.password.length }}
                  / {{ max }} </mat-hint>
                <mat-error *ngIf="sigInPasswordFormControl.hasError('required')">
                  {{passwordErrorRequiredText}}
                </mat-error>
                <mat-error *ngIf="sigInPasswordFormControl.hasError('minlength')">
                  {{ passwordErrorMinLengthText }}
                </mat-error>
                <mat-error *ngIf="sigInPasswordFormControl.hasError('maxlength')">
                  {{ passwordErrorMaxLengthText }}
                </mat-error>
              </mat-form-field>

              <button [@animate]="{ value: '*', params: { x: '50px' } }"
                    mat-raised-button
                      style="margin-top: 20px"
                      type="submit"
                      class="space-top"
                      [color]="color"
                      [disabled]="signInFormGroup.invalid">
                {{loginButtonText}}
              </button>

            </div>
          </form>

          <div fxLayoutAlign="center">
            <button *ngIf="resetPasswordEnabled"
                    [@animate]="{ value: '*', params: { x: '-50px' } }"
                  mat-button
                  class="space-top"
                  [color]="color"
                  (click)="createForgotPasswordTab()">
            {{forgotPasswordButtonText}}
          </button>
        </div>

        </mat-card-content>
        <mat-card-footer *ngIf="isLoading">
          <mat-progress-bar [@animate]="{ value: '*', params: { z: '50px', delay: '50ms', scale: '0.2' } }"
                          mode="indeterminate"></mat-progress-bar>
        </mat-card-footer>
      </mat-card>
    </mat-tab>

    <!--tab register-->
    <mat-tab [label]="registerTabText" *ngIf="registrationEnabled">
      <mat-card>
        <mat-card-title>{{registerCardTitleText}}</mat-card-title>
          <mat-card-content fxLayout="column" fxLayoutAlign="center">
            <form [@animateStagger]="{ value: '50' }"
                [formGroup]="signUpFormGroup" (ngSubmit)="signUpFormGroup.valid &&
            processLegalSignUP(authProvider.EmailAndPassword)">
              <div fxLayout="column" fxLayoutAlign="center">
                <!--name-->
                <mat-form-field [@animate]="{ value: '*', params: { x: '50px' } }"
                              [appearance]="appearance">
                  <!--labels will work only with @angular/material@6.2.0 -->
                  <mat-label>{{nameText}}</mat-label>
                  <input
                    matInput
                    [minlength]="config.nameMinLength"
                    [maxlength]="config.nameMaxLength"
                    [formControl]="sigUpNameFormControl"
                    required
                  />
                  <mat-icon matSuffix [color]="color">person</mat-icon>
                  <mat-hint align="end" aria-live="polite"> {{ signUpFormGroup.value.name?.length }}
                    / {{ config.nameMaxLength }} </mat-hint>
                  <mat-error *ngIf="sigUpNameFormControl.hasError('required')">
                    {{nameErrorRequiredText}}
                  </mat-error>
                  <mat-error *ngIf="sigUpNameFormControl.hasError('minlength')">
                    {{nameErrorMinLengthText}}
                  </mat-error>
                  <mat-error *ngIf="sigUpNameFormControl.hasError('maxlength')">
                    {{nameErrorMaxLengthText}}
                  </mat-error>
                </mat-form-field>

                <!--email-->
                <mat-form-field [@animate]="{ value: '*', params: { x: '50px' } }"
                              [appearance]="appearance">
                  <mat-label>{{emailText}}</mat-label>
                  <input matInput
                        type="email"
                        [formControl]="sigUpEmailFormControl"
                        required>
                  <mat-icon matSuffix [color]="color">email</mat-icon>
                  <mat-error *ngIf="sigUpEmailFormControl.hasError('required')">
                    {{emailErrorRequiredText}}
                  </mat-error>
                  <mat-error *ngIf="sigUpEmailFormControl.hasError('pattern')">
                    {{emailErrorPatternText}}
                  </mat-error>
                </mat-form-field>

                <!--password-->
                <div fxLayout="column">
                  <mat-form-field [@animate]="{ value: '*', params: { x: '50px' } }"
                                [appearance]="appearance">
                    <mat-label>{{passwordText}}</mat-label>
                    <input
                      matInput
                      [type]="toggle.type"
                      name="password"
                      [formControl]="sigUpPasswordFormControl"
                      required
                      [minlength]="min"
                      [maxlength]="max"
                    />
                    <mat-pass-toggle-visibility #toggle matSuffix></mat-pass-toggle-visibility>

                    <mat-icon matSuffix [color]="color">lock</mat-icon>

                    <mat-hint align="end" aria-live="polite">
                      {{signUpFormGroup.value.password?.length}} / {{ max }}
                    </mat-hint>

                    <mat-error *ngIf="sigUpPasswordFormControl.hasError('required')" class="cut-text">
                      {{passwordErrorRequiredText}}
                    </mat-error>

                    <mat-error *ngIf="sigUpPasswordFormControl.hasError('minlength')" class="cut-text">
                      {{ passwordErrorMinLengthText }}
                    </mat-error>
                    <mat-error *ngIf="sigUpPasswordFormControl.hasError('maxlength')" class="cut-text">
                      {{ passwordErrorMaxLengthText }}
                    </mat-error>

                  </mat-form-field>

                  <mat-password-strength #passwordStrength
                                        [min]="min"
                                        [max]="max"
                                        [customValidator]="customValidator"
                                        [enableLengthRule]="enableLengthRule"
                                        [enableLowerCaseLetterRule]="enableLowerCaseLetterRule"
                                        [enableUpperCaseLetterRule]="enableUpperCaseLetterRule"
                                        [enableDigitRule]="enableDigitRule"
                                        [enableSpecialCharRule]="enableSpecialCharRule"
                                        [password]="signUpFormGroup.value.password"
                                        [externalError]="sigUpPasswordFormControl.dirty">
                  </mat-password-strength>

                </div>

                <button [@animate]="{ value: '*', params: { x: '100px' } }"
                      mat-raised-button
                        style="margin-top: 20px"
                        type="submit"
                        [disabled]="signUpFormGroup.invalid"
                        [color]="color">
                  {{registerButtonText}}
                </button>

              </div>
            </form>

            <button *ngIf="guestEnabled"
                    [@animate]="{ value: '*', params: { x: '-100px' } }"
                  mat-button
                  style="margin-top: 20px"
                  [color]="color"
                  (click)="processLegalSignUP(authProvider.ANONYMOUS)">
            <mat-icon>fingerprint</mat-icon>
            {{guestButtonText}}
          </button>

          </mat-card-content>

          <mat-card-footer *ngIf="isLoading">
            <mat-progress-bar [@animate]="{ value: '*', params: { z: '50px', delay: '50ms', scale: '0.2' } }"
                            mode="indeterminate"></mat-progress-bar>
          </mat-card-footer>

      </mat-card>
    </mat-tab>

    <!--Reset password tab-->
    <mat-tab *ngIf="passwordResetWished" class="reset-password-tab">
      <ng-template mat-tab-label>
        <button mat-icon-button class="reset-password-tab__close-button" (click)="passwordResetWished = false">
          {{ resetPasswordTabText }}
          <mat-icon>close</mat-icon>
        </button>
      </ng-template>
      <form [@animateStagger]="{ value: '50' }"
            [formGroup]="resetPasswordFormGroup"
            (ngSubmit)="resetPasswordFormGroup.valid && resetPassword()">
        <mat-card class="reset-password-card">
          <mat-card-content>
            <mat-form-field [@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}" class="full-width"
                            [appearance]="appearance">
              <mat-label> {{ resetPasswordInputText }} </mat-label>
              <input matInput
                    [title]="resetPasswordInputText"
                    formControlName="email"
                    required>
              <mat-icon matSuffix [color]="color">email</mat-icon>
              <mat-error *ngIf="resetPasswordEmailFormControl.hasError('required')">
                {{resetPasswordErrorRequiredText}}
              </mat-error>
              <mat-error *ngIf="resetPasswordEmailFormControl.hasError('pattern')">
                {{resetPasswordErrorPatternText}}
              </mat-error>
            </mat-form-field>
            <p *ngIf="passReset">{{resetPasswordInstructionsText}}</p>
          </mat-card-content>
          <mat-card-actions fxLayoutAlign="center">
            <mat-progress-bar *ngIf="isLoading" mode="indeterminate"></mat-progress-bar>
            <button [@animate]="{ value: '*', params: { x: '50px' } }"
                    mat-raised-button
                    type="submit"
                    [color]="color">
              {{resetPasswordActionButtonText}}
            </button>
          </mat-card-actions>
        </mat-card>
      </form>
    </mat-tab>

  </mat-tab-group>
  <mat-divider></mat-divider>
  <ngx-auth-firebaseui-providers *ngIf="tabIndex !== 2"
                                 [providers]="providers"
                                 [theme]="providersTheme">
  </ngx-auth-firebaseui-providers>
</ng-template>

auth.component.scss

.mat-card {
  margin: 2rem;
}

.space-top {
  margin-top: .5rem;
}

.full-width {
  width: 100%;
}

.cut-text {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.signed-in-container {
  .account-circle {
    font-size: 12rem;
    width: 12rem;
    height: 12rem;
  }
  img.account-circle {
    object-fit: cover;
    border-radius: 50%;
  }
  .sign-out-button {
    margin-top: 2rem;
  }
  .user-display-name {
    margin-top: 1rem;
  }
  .user-email {
    margin-top: -1rem;
  }
  .actions {
    margin-top: 2rem;
    .action-button, mat-progress-bar {
      width: 100%;
    }
    .action-button {
      margin-top: 1rem;
    }
  }
}

.reset-password-tab {
  mat-progress-bar {
    margin-bottom: 1rem;
  }
  &__close-button {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    mat-icon {
      font-size: 18px;
      position: relative;
      top: -1px;
    }
  }
}
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""