Skip to content

Commit

Permalink
fix(package): assign default config after initializing the main compo…
Browse files Browse the repository at this point in the history
…nent # 190
  • Loading branch information
AnthonyNahas committed Feb 24, 2019
1 parent b428970 commit 5684afd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/module/components/auth/auth.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {Subscription} from 'rxjs/internal/Subscription';
import {AuthProcessService, AuthProvider} from '../../services/auth-process.service';
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 {defaultAuthFirebaseUIConfig} from '../../interfaces/config.interface';


export const EMAIL_REGEX = new RegExp(['^(([^<>()[\\]\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\.,;:\\s@\"]+)*)',
Expand Down Expand Up @@ -83,6 +85,7 @@ export class AuthComponent implements OnInit, OnChanges, OnDestroy {
resetPasswordEmailFormControl: AbstractControl;

constructor(@Inject(PLATFORM_ID) private platformId: Object,
@Inject(NgxAuthFirebaseUIConfigToken) private config: NgxAuthFirebaseUIConfig,
public auth: AngularFireAuth,
public authProcess: AuthProcessService,
public dialog: MatDialog) {
Expand All @@ -92,6 +95,8 @@ export class AuthComponent implements OnInit, OnChanges, OnDestroy {
}

public ngOnInit(): void {
this.config = Object.assign(defaultAuthFirebaseUIConfig, this.config);

if (isPlatformBrowser(this.platformId)) {
this.onErrorSubscription = this.onError.subscribe(() => this.authenticationError = true);
}
Expand Down
3 changes: 2 additions & 1 deletion src/module/guards/logged-in.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export class LoggedInGuard implements CanActivate {
private config: NgxAuthFirebaseUIConfig,
private router: Router,
private auth: AuthProcessService,
) {}
) {
}

canActivate(): Observable<boolean> {
return this.auth.afa.user.pipe(
Expand Down
2 changes: 1 addition & 1 deletion src/module/ngx-auth-firebase-u-i.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const NgxAuthFirebaseUIConfigToken = new InjectionToken<NgxAuthFirebaseUI
export class NgxAuthFirebaseUIModule {
static forRoot(configFactory: FirebaseAppConfig,
appNameFactory?: () => string,
config?: NgxAuthFirebaseUIConfig): ModuleWithProviders {
config: NgxAuthFirebaseUIConfig = defaultAuthFirebaseUIConfig): ModuleWithProviders {
return {
ngModule: NgxAuthFirebaseUIModule,
providers:
Expand Down
3 changes: 2 additions & 1 deletion src/module/services/auth-process.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export class AuthProcessService implements ISignInProcess, ISignUpProcess {
* @returns
*/
public async signInWith(provider: AuthProvider, credentials?: ICredentials) {
// console.log('this.config on signInWith', this.config);
try {
this.isLoading = true;
let signInResult: UserCredential | any;
Expand Down Expand Up @@ -102,7 +103,7 @@ export class AuthProcessService implements ISignInProcess, ISignUpProcess {
break;

case AuthProvider.PhoneNumber:

// coming soon - see feature/sms branch
break;

default:
Expand Down

0 comments on commit 5684afd

Please sign in to comment.