mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-15 09:42:56 -07:00
Fixed the issue where the sidebar nav doesn't load
This commit is contained in:
parent
9f5c19ecf6
commit
e141743f08
4 changed files with 18 additions and 21 deletions
|
@ -167,8 +167,8 @@
|
|||
|
||||
|
||||
|
||||
<div [ngClass]="user.name && roleClass()">
|
||||
<app-my-nav [showNav]="showNav" [isAdmin]="isAdmin" [applicationName]="applicationName" [username]="user.name" (logoutClick)="logOut();"
|
||||
<div>
|
||||
<app-my-nav [showNav]="showNav" [isAdmin]="isAdmin" [applicationName]="applicationName" [username]="username" (logoutClick)="logOut();"
|
||||
(themeChange)="onSetTheme($event)"></app-my-nav>
|
||||
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ export class AppComponent implements OnInit {
|
|||
public voteEnabled = false;
|
||||
public applicationName: string = "Ombi"
|
||||
public isAdmin: boolean;
|
||||
public username: string;
|
||||
|
||||
private checkedForUpdate: boolean;
|
||||
|
||||
|
@ -86,6 +87,9 @@ export class AppComponent implements OnInit {
|
|||
this.currentUrl = event.url;
|
||||
if (event instanceof NavigationStart) {
|
||||
this.user = this.authService.claims();
|
||||
if(this.user && this.user.username) {
|
||||
this.username = this.user.username;
|
||||
}
|
||||
this.isAdmin = this.authService.hasRole("admin");
|
||||
this.showNav = this.authService.loggedIn();
|
||||
|
||||
|
@ -101,17 +105,6 @@ export class AppComponent implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
public roleClass() {
|
||||
if (this.user) {
|
||||
if (this.user.roles.some(r => r === "Admin")) {
|
||||
return "adminUser";
|
||||
} else if (this.user.roles.some(r => r === "PowerUser")) {
|
||||
return "powerUser";
|
||||
}
|
||||
}
|
||||
return "user";
|
||||
}
|
||||
|
||||
public openMobileApp(event: any) {
|
||||
event.preventDefault();
|
||||
if (!this.customizationSettings.applicationUrl) {
|
||||
|
|
|
@ -11,4 +11,5 @@ export interface IUserLogin {
|
|||
export interface ILocalUser {
|
||||
roles: string[];
|
||||
name: string;
|
||||
username:string;
|
||||
}
|
||||
|
|
|
@ -59,8 +59,11 @@ export class AuthService extends ServiceHelpers {
|
|||
}
|
||||
|
||||
public hasRole(role: string): boolean {
|
||||
if (this.claims().roles) {
|
||||
return this.claims().roles.some(r => r.toUpperCase() === role.toUpperCase());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public logout() {
|
||||
localStorage.removeItem("id_token");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue