-
-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: feat: add option to hide connected user panel #483
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
11 | ||
12 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
- 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" | ||
*ngIf="isEmailConfirmationScreenVisible(user)" | ||
fxLayout="row" fxLayoutAlign="center center"> | ||
<ngx-auth-firebaseui-email-confirmation | ||
(signOut)="signOut()" | ||
|
@@ -21,23 +21,21 @@ | |
</ngx-auth-firebaseui-email-confirmation> | ||
</div> | ||
|
||
<ng-template #signedInUser> | ||
<div class="signed-in-container" fxLayout="column" fxLayoutAlign="center center"> | ||
<img *ngIf="user?.photoURL; else noPhoto" [src]="user?.photoURL" class="account-circle"> | ||
<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 [routerLink]="goBackURL" class="go-back-button action-button" color="primary" | ||
mat-stroked-button>{{ verifyEmailGoBackText }}</a> | ||
<button (click)="signOut()" class="sign-out-button action-button" color="warn" | ||
mat-stroked-button>{{ signOutText }}</button> | ||
</div> | ||
<div *ngIf="isUserProfileScreenVisible(user)" class="signed-in-container" fxLayout="column" fxLayoutAlign="center center" *ngIf=""> | ||
<img *ngIf="user?.photoURL; else noPhoto" [src]="user?.photoURL" class="account-circle"> | ||
<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 [routerLink]="goBackURL" class="go-back-button action-button" color="primary" | ||
mat-stroked-button>{{ verifyEmailGoBackText }}</a> | ||
<button (click)="signOut()" class="sign-out-button action-button" color="warn" | ||
mat-stroked-button>{{ signOutText }}</button> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see above for detail :) |
||
</div> | ||
</ng-template> | ||
</div> | ||
|
||
</ng-container> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,7 @@ export class AuthComponent implements OnInit, AfterViewInit, OnChanges, OnDestro | |
@Input() tabIndex: number | null; | ||
@Input() registrationEnabled = true; | ||
@Input() resetPasswordEnabled = true; | ||
@Input() connectedUserScreenEnabled = true; | ||
@Input() guestEnabled = true; | ||
@Input() tosUrl: string; | ||
@Input() privacyPolicyUrl: string; | ||
|
@@ -85,6 +86,7 @@ export class AuthComponent implements OnInit, AfterViewInit, OnChanges, OnDestro | |
// tslint:disable-next-line:no-output-on-prefix | ||
@Output() onError: any; | ||
@Output() selectedTabChange: EventEmitter<MatTabChangeEvent> = new EventEmitter(); | ||
@Output() loading: EventEmitter<boolean> = new EventEmitter(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need a new event emitter ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the new event emitter was added in case we want to alert the container component something inside is loading. Can be useful to display a loader over the whole container. It doesn't disturb the flow. I can remove it though |
||
|
||
// Password strength api | ||
@Input() enableLengthRule = true; | ||
|
@@ -192,6 +194,15 @@ export class AuthComponent implements OnInit, AfterViewInit, OnChanges, OnDestro | |
return this.authenticationError ? 'warn' : 'primary'; | ||
} | ||
|
||
public isEmailConfirmationScreenVisible(user: firebase.User): boolean { | ||
return (this.config.guardProtectedRoutesUntilEmailIsVerified && !user.emailVerified) | ||
|| (this.authProcess.emailConfirmationSent && !user.emailVerified); | ||
} | ||
|
||
public isUserProfileScreenVisible(user: firebase.User): boolean { | ||
return !this.isEmailConfirmationScreenVisible(user) && this.connectedUserScreenEnabled; | ||
} | ||
|
||
public ngOnInit(): void { | ||
if (isPlatformBrowser(this.platformId)) { | ||
this.onErrorSubscription = this.onError.subscribe(() => this.authenticationError = true); | ||
|
@@ -245,10 +256,12 @@ export class AuthComponent implements OnInit, AfterViewInit, OnChanges, OnDestro | |
async signOut() { | ||
try { | ||
this.isLoading = true; | ||
this.loading.emit(true); | ||
this.changeDetectorRef.markForCheck(); | ||
await this.authProcess.signOut(); | ||
} finally { | ||
this.isLoading = false; | ||
this.loading.emit(false); | ||
this.changeDetectorRef.markForCheck(); | ||
} | ||
} | ||
|
@@ -259,13 +272,15 @@ export class AuthComponent implements OnInit, AfterViewInit, OnChanges, OnDestro | |
} | ||
try { | ||
this.isLoading = true; | ||
this.loading.emit(true); | ||
this.changeDetectorRef.markForCheck(); | ||
await this.authProcess.signInWith(this.authProviders.EmailAndPassword, { | ||
email: this.signInFormGroup.value.email, | ||
password: this.signInFormGroup.value.password | ||
}); | ||
} finally { | ||
this.isLoading = false; | ||
this.loading.emit(false); | ||
this.changeDetectorRef.markForCheck(); | ||
} | ||
} | ||
|
@@ -304,6 +319,7 @@ export class AuthComponent implements OnInit, AfterViewInit, OnChanges, OnDestro | |
async signUp() { | ||
try { | ||
this.isLoading = true; | ||
this.loading.emit(true); | ||
this.changeDetectorRef.markForCheck(); | ||
return await this.authProcess.signUp( | ||
this.signUpFormGroup.value.name, | ||
|
@@ -314,22 +330,24 @@ export class AuthComponent implements OnInit, AfterViewInit, OnChanges, OnDestro | |
); | ||
} finally { | ||
this.isLoading = false; | ||
this.loading.emit(false); | ||
this.changeDetectorRef.markForCheck(); | ||
} | ||
} | ||
|
||
async signUpAnonymously() { | ||
try { | ||
this.isLoading = true; | ||
this.loading.emit(true); | ||
this.changeDetectorRef.markForCheck(); | ||
await this.authProcess.signInWith(this.authProvider.ANONYMOUS); | ||
} finally { | ||
this.isLoading = false; | ||
this.loading.emit(false); | ||
this.changeDetectorRef.markForCheck(); | ||
} | ||
} | ||
|
||
|
||
resetPassword() { | ||
this.authProcess.resetPassword(this.resetPasswordEmailFormControl.value) | ||
.then(() => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can u please provide more info about the implementation and why the logic should change ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In current implementation, only two "alternatives" are covered:
My proposal is to offer a third option (implementation detail: I moved the condition in a method so the HTML is more readable).
To allow this third option i removed the
if ; else
syntax, thus removing the ng-template. After my change we basically have 3 options:Since everything has parameters in ngx-auth-firebaseui, it's nice to allow developper not to display something and allowing him to use the new ngx-auth-firebaseui with signin/register/email validation guard without forcing display of profile after login.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will perform more tests to find if there is another way to achieve this :)