Small user changes #865

pull/1425/head
Jamie.Rees 7 years ago
parent b4789363e8
commit 8a98761fec

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

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

@ -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"));
}
}
Loading…
Cancel
Save