diff --git a/src/Ombi/ClientApp/src/app/app.component.html b/src/Ombi/ClientApp/src/app/app.component.html index 6e9a8b2d5..635693765 100644 --- a/src/Ombi/ClientApp/src/app/app.component.html +++ b/src/Ombi/ClientApp/src/app/app.component.html @@ -167,8 +167,8 @@ -
- + diff --git a/src/Ombi/ClientApp/src/app/app.component.ts b/src/Ombi/ClientApp/src/app/app.component.ts index d16fdc0e1..fcea0adfe 100644 --- a/src/Ombi/ClientApp/src/app/app.component.ts +++ b/src/Ombi/ClientApp/src/app/app.component.ts @@ -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) { diff --git a/src/Ombi/ClientApp/src/app/auth/IUserLogin.ts b/src/Ombi/ClientApp/src/app/auth/IUserLogin.ts index d0e4d374a..4a24798d4 100644 --- a/src/Ombi/ClientApp/src/app/auth/IUserLogin.ts +++ b/src/Ombi/ClientApp/src/app/auth/IUserLogin.ts @@ -11,4 +11,5 @@ export interface IUserLogin { export interface ILocalUser { roles: string[]; name: string; + username:string; } diff --git a/src/Ombi/ClientApp/src/app/auth/auth.service.ts b/src/Ombi/ClientApp/src/app/auth/auth.service.ts index 5d181171c..afd38b822 100644 --- a/src/Ombi/ClientApp/src/app/auth/auth.service.ts +++ b/src/Ombi/ClientApp/src/app/auth/auth.service.ts @@ -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 { - 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 { - return this.http.get(`${this.url}/${pin}`, {headers: this.headers}); + return this.http.get(`${this.url}/${pin}`, { headers: this.headers }); } public requiresPassword(login: IUserLogin): Observable { - return this.http.post(`${this.url}/requirePassword`, JSON.stringify(login), {headers: this.headers}); + return this.http.post(`${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 u; + return u; } - return { }; + return {}; } 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() {