Simplified unnecessary complex logic
This commit is contained in:
parent
02fbd0984e
commit
5f3649990f
overlord/src/app/core
@ -64,18 +64,18 @@
|
||||
<span class="fill-remaining-space"></span>
|
||||
|
||||
<mat-menu #userMenu="matMenu">
|
||||
<a mat-menu-item routerLink="/logout">Logout {{nameObject | async}}</a>
|
||||
<a mat-menu-item routerLink="/users/{{nameObject | async}}">Change Password</a>
|
||||
<a mat-menu-item (click)="logout()">Logout {{(auth.currentUser | async)?.name}}</a>
|
||||
<a mat-menu-item routerLink="/users/me">Change Password</a>
|
||||
<a mat-menu-item routerLink="/users">Users</a>
|
||||
<a mat-menu-item routerLink="/groups">Groups</a>
|
||||
<a mat-menu-item routerLink="/clients">Clients</a>
|
||||
<a mat-menu-item routerLink="/settings">Settings</a>
|
||||
</mat-menu>
|
||||
<button mat-button [matMenuTriggerFor]="userMenu" *ngIf="nameObject | async as name">
|
||||
<button mat-button [matMenuTriggerFor]="userMenu" *ngIf="(auth.currentUser | async)?.name as name">
|
||||
<mat-icon>account_box</mat-icon>
|
||||
{{name}}
|
||||
</button>
|
||||
<a mat-button routerLink="/login" *ngIf="!(nameObject | async)">
|
||||
<a mat-button routerLink="/login" *ngIf="!(auth.currentUser | async)">
|
||||
<mat-icon>account_box</mat-icon>
|
||||
Login</a>
|
||||
</mat-toolbar>
|
||||
|
@ -1,25 +1,19 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component} from '@angular/core';
|
||||
import {AuthService} from '../../auth/auth.service';
|
||||
import {Subject} from 'rxjs/internal/Subject';
|
||||
import {Router} from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-nav-bar',
|
||||
templateUrl: './nav-bar.component.html',
|
||||
styleUrls: ['./nav-bar.component.css']
|
||||
})
|
||||
export class NavBarComponent implements OnInit {
|
||||
public nameObject = new Subject<string>();
|
||||
export class NavBarComponent {
|
||||
|
||||
constructor(private auth: AuthService) {
|
||||
constructor(private router: Router, private auth: AuthService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.auth.userObservable.subscribe((user) => {
|
||||
if (user.isAuthenticated) {
|
||||
this.nameObject.next(user.name);
|
||||
} else {
|
||||
this.nameObject.next(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
logout() {
|
||||
this.auth.logout();
|
||||
this.router.navigate(['/']);
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,11 @@ export class User {
|
||||
name: string;
|
||||
password: string;
|
||||
lockedOut: boolean;
|
||||
groups: UserGroup[];
|
||||
roles?: UserGroup[];
|
||||
perms: string[];
|
||||
isAuthenticated: boolean;
|
||||
access_token?: string;
|
||||
exp?: bigint;
|
||||
|
||||
public constructor(init?: Partial<User>) {
|
||||
Object.assign(this, init);
|
||||
|
Loading…
x
Reference in New Issue
Block a user