get user email from Principal fixed

This commit is contained in:
gpapavgeri 2020-07-17 13:42:39 +03:00
parent ac24143c0d
commit 1fd4c8e05f
3 changed files with 7 additions and 12 deletions

View File

@ -4,7 +4,7 @@
<mat-divider class="col-12 top-divider"></mat-divider>
<div class="col-12 pl-2">
<a class="profile email-btn mt-2 mb-2 pl-0">
<mat-icon class="check-icon">check</mat-icon>{{ data.user.email }}
<mat-icon class="check-icon">check</mat-icon>{{ getPrincipalEmail() }}
</a>
</div>
<mat-divider class="col-12"></mat-divider>

View File

@ -35,6 +35,12 @@ export class UserDialogComponent implements OnInit {
return '';
}
public getPrincipalEmail(): string {
const principal: Principal = this.authentication.current();
if (principal) { return principal.email; }
return '';
}
public principalHasAvatar(): boolean {
return this.authentication.current() && this.authentication.current().avatarUrl != null && this.authentication.current().avatarUrl.length > 0;
}

View File

@ -73,7 +73,6 @@ export class NavbarComponent extends BaseComponent implements OnInit {
this.progressIndicationService.getProgressIndicationObservable().pipe(takeUntil(this._destroyed)).subscribe(x => {
setTimeout(() => { this.progressIndication = x; });
});
this.getPrincipalAsUser();
}
public isAuthenticated(): boolean {
@ -84,13 +83,6 @@ export class NavbarComponent extends BaseComponent implements OnInit {
return this.currentRoute === '/language-editor' || this.currentRoute === '/profile';
}
public getPrincipalAsUser() {
const principal: Principal = this.authentication.current();
if (principal) {
this.userService.getUser(principal.id).pipe(takeUntil(this._destroyed)).subscribe(result => this.user = result);
}
}
sidebarOpen() {
const toggleButton = this.toggleButton;
const body = document.getElementsByTagName('body')[0];
@ -223,9 +215,6 @@ export class NavbarComponent extends BaseComponent implements OnInit {
autoFocus: false,
closeOnNavigation: true,
disableClose: false,
data: {
user: this.user
},
position: { top: '64px', right: '1em' }
});
}