diff --git a/overlord/src/app/core/nav-bar/nav-bar.component.html b/overlord/src/app/core/nav-bar/nav-bar.component.html index baf2fc8d..0dcf77c3 100644 --- a/overlord/src/app/core/nav-bar/nav-bar.component.html +++ b/overlord/src/app/core/nav-bar/nav-bar.component.html @@ -64,18 +64,18 @@ - Logout {{nameObject | async}} - Change Password + Logout {{(auth.currentUser | async)?.name}} + Change Password Users Groups Clients Settings - - + account_box Login diff --git a/overlord/src/app/core/nav-bar/nav-bar.component.ts b/overlord/src/app/core/nav-bar/nav-bar.component.ts index 8eae9e40..b9588985 100644 --- a/overlord/src/app/core/nav-bar/nav-bar.component.ts +++ b/overlord/src/app/core/nav-bar/nav-bar.component.ts @@ -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(); +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(['/']); + } } diff --git a/overlord/src/app/core/user.ts b/overlord/src/app/core/user.ts index 2dd641fd..9bf7d5e3 100644 --- a/overlord/src/app/core/user.ts +++ b/overlord/src/app/core/user.ts @@ -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) { Object.assign(this, init);