From 8a98761fecfd0fd1985237ed9a56142ace45dd15 Mon Sep 17 00:00:00 2001 From: "Jamie.Rees" Date: Wed, 24 May 2017 16:31:36 +0100 Subject: [PATCH] Small user changes #865 --- src/Ombi/wwwroot/app/app.component.ts | 2 ++ src/Ombi/wwwroot/app/auth/auth.service.ts | 2 +- src/Ombi/wwwroot/app/login/login.component.ts | 26 +++++++------------ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/Ombi/wwwroot/app/app.component.ts b/src/Ombi/wwwroot/app/app.component.ts index 3b4c981fe..4fd7e2d9d 100644 --- a/src/Ombi/wwwroot/app/app.component.ts +++ b/src/Ombi/wwwroot/app/app.component.ts @@ -34,6 +34,8 @@ export class AppComponent implements OnInit { this.settingsService.getCustomization().subscribe(x => this.customizationSettings = x); this.router.events.subscribe(() => { + + this.user = this.authService.claims(); this.showNav = this.authService.loggedIn(); }); diff --git a/src/Ombi/wwwroot/app/auth/auth.service.ts b/src/Ombi/wwwroot/app/auth/auth.service.ts index 4a2f55bfa..a4ea52f20 100644 --- a/src/Ombi/wwwroot/app/auth/auth.service.ts +++ b/src/Ombi/wwwroot/app/auth/auth.service.ts @@ -40,7 +40,7 @@ export class AuthService extends ServiceHelpers { var u = { name: name, roles: [] as string[] }; if (roles instanceof Array) { - u.roles.concat(roles); + u.roles = roles; } else { u.roles.push(roles); } diff --git a/src/Ombi/wwwroot/app/login/login.component.ts b/src/Ombi/wwwroot/app/login/login.component.ts index 506fdc0cd..6c725f8c8 100644 --- a/src/Ombi/wwwroot/app/login/login.component.ts +++ b/src/Ombi/wwwroot/app/login/login.component.ts @@ -26,25 +26,17 @@ export class LoginComponent { login(): void { - this.authService.login({ password: this.password, username: this.username }) - .subscribe(x => { - localStorage.setItem("id_token", x.access_token); - localStorage.setItem('currentUser', this.username); + this.authService.login({ password: this.password, username: this.username }) + .subscribe(x => { + localStorage.setItem("id_token", x.access_token); - this.identityService.getUser().subscribe(r => { - localStorage.setItem("roles", JSON.stringify(r.claims)); - localStorage.setItem("user", JSON.stringify(r)); + if (this.authService.loggedIn()) { + this.router.navigate(['search']); + } else { + this.notify.error("Could not log in", "Incorrect username or password"); + } - if (this.authService.loggedIn()) { - this.router.navigate(['search']); - } else { - this.notify.error("Could not log in", "Incorrect username or password"); - } - }); - - }, err => this.notify.error("Could not log in", "Incorrect username or password")); - - + }, err => this.notify.error("Could not log in", "Incorrect username or password")); } } \ No newline at end of file