Fixed the issue where the sidebar nav doesn't load

pull/3895/head
Jamie Rees 5 years ago
parent 9f5c19ecf6
commit e141743f08

@ -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;
}

@ -10,20 +10,20 @@ import { ILocalUser, IUserLogin } from "./IUserLogin";
@Injectable()
export class AuthService extends ServiceHelpers {
constructor(http: HttpClient, @Inject(APP_BASE_HREF) href:string, private jwtHelperService: JwtHelperService) {
constructor(http: HttpClient, @Inject(APP_BASE_HREF) href: string, private jwtHelperService: JwtHelperService) {
super(http, "/api/v1/token", href);
}
public login(login: IUserLogin): Observable<any> {
return this.http.post(`${this.url}/`, JSON.stringify(login), {headers: this.headers});
return this.http.post(`${this.url}/`, JSON.stringify(login), { headers: this.headers });
}
public oAuth(pin: number): Observable<any> {
return this.http.get<any>(`${this.url}/${pin}`, {headers: this.headers});
return this.http.get<any>(`${this.url}/${pin}`, { headers: this.headers });
}
public requiresPassword(login: IUserLogin): Observable<boolean> {
return this.http.post<boolean>(`${this.url}/requirePassword`, JSON.stringify(login), {headers: this.headers});
return this.http.post<boolean>(`${this.url}/requirePassword`, JSON.stringify(login), { headers: this.headers });
}
public loggedIn() {
@ -49,17 +49,20 @@ export class AuthService extends ServiceHelpers {
const u = { name, roles: [] as string[] };
if (roles instanceof Array) {
u.roles = roles;
u.roles = roles;
} else {
u.roles.push(roles);
}
return <ILocalUser> u;
return <ILocalUser>u;
}
return <ILocalUser> { };
return <ILocalUser>{};
}
public hasRole(role: string): boolean {
return this.claims().roles.some(r => r.toUpperCase() === role.toUpperCase());
if (this.claims().roles) {
return this.claims().roles.some(r => r.toUpperCase() === role.toUpperCase());
}
return false;
}
public logout() {

Loading…
Cancel
Save