@@ -12,7 +12,7 @@ import {
1212 ViewChild
1313} from '@angular/core' ;
1414import { AbstractControl , FormControl , FormGroup , Validators } from '@angular/forms' ;
15- import { MatDialog , MatDialogRef , MatFormFieldAppearance , MatTabChangeEvent , MatTabGroup } from '@angular/material' ;
15+ import { MatDialog , MatDialogRef , MatFormFieldAppearance , MatTabChangeEvent , MatTabGroup , ThemePalette } from '@angular/material' ;
1616import { AngularFireAuth } from '@angular/fire/auth' ;
1717import { isPlatformBrowser } from '@angular/common' ;
1818import { Subscription } from 'rxjs/internal/Subscription' ;
@@ -22,6 +22,7 @@ import {LegalityDialogComponent} from '../../components/legality-dialog/legality
2222import { LegalityDialogParams , LegalityDialogResult } from '../../interfaces/legality.dialog.intreface' ;
2323import { NgxAuthFirebaseUIConfig , NgxAuthFirebaseUIConfigToken } from '../../ngx-auth-firebase-u-i.module' ;
2424import { defaultAuthFirebaseUIConfig } from '../../interfaces/config.interface' ;
25+ import { MatPasswordStrengthComponent } from '@angular-material-extensions/password-strength' ;
2526
2627
2728export const EMAIL_REGEX = new RegExp ( [ '^(([^<>()[\\]\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\.,;:\\s@\"]+)*)' ,
@@ -40,6 +41,7 @@ export const PHONE_NUMBER_REGEX = new RegExp(/^\+(?:[0-9] ?){6,14}[0-9]$/);
4041export class AuthComponent implements OnInit , OnChanges , OnDestroy {
4142
4243 @ViewChild ( MatTabGroup , { static : false } ) matTabGroup : MatTabGroup ;
44+ @ViewChild ( MatPasswordStrengthComponent , { static : false } ) passwordStrength : MatPasswordStrengthComponent ;
4345
4446 @Input ( ) providers : string [ ] | string = AuthProvider . ALL ; // google, facebook, twitter, github as array or all as one single string
4547 @Input ( ) appearance : MatFormFieldAppearance ;
@@ -53,6 +55,17 @@ export class AuthComponent implements OnInit, OnChanges, OnDestroy {
5355 @Input ( ) messageOnAuthSuccess : string ;
5456 @Input ( ) messageOnAuthError : string ;
5557
58+ // Password strength api
59+ @Input ( ) enableLengthRule = true ;
60+ @Input ( ) enableLowerCaseLetterRule = true ;
61+ @Input ( ) enableUpperCaseLetterRule = true ;
62+ @Input ( ) enableDigitRule = true ;
63+ @Input ( ) enableSpecialCharRule = true ;
64+ @Input ( ) min = 8 ;
65+ @Input ( ) max = 30 ;
66+ @Input ( ) customValidator : RegExp ;
67+ @Output ( ) onStrengthChanged : EventEmitter < number > = new EventEmitter ( ) ;
68+
5669 // Customize the text
5770 // Reset Password Tab
5871 @Input ( ) resetPasswordTabText = 'Reset e-mail address to password' ;
@@ -127,6 +140,7 @@ export class AuthComponent implements OnInit, OnChanges, OnDestroy {
127140
128141 public ngOnInit ( ) : void {
129142 this . config = Object . assign ( defaultAuthFirebaseUIConfig , this . config ) ;
143+ this . onStrengthChanged = this . passwordStrength . onStrengthChanged ;
130144
131145 if ( isPlatformBrowser ( this . platformId ) ) {
132146 this . onErrorSubscription = this . onError . subscribe ( ( ) => this . authenticationError = true ) ;
@@ -154,7 +168,7 @@ export class AuthComponent implements OnInit, OnChanges, OnDestroy {
154168 this . selectedTabChange . emit ( event ) ;
155169 }
156170
157- get color ( ) : string {
171+ get color ( ) : string | ThemePalette {
158172 return this . authenticationError ? 'warn' : 'primary' ;
159173 }
160174
0 commit comments