basic account management (Login/Logout)

This commit is contained in:
VLE2FE
2020-07-14 09:39:37 +02:00
parent b28be4b792
commit e6e5c22ece
12 changed files with 195 additions and 46 deletions

View File

@ -42,6 +42,11 @@ export class LoginService implements CanActivate {
});
}
logout() {
this.storage.remove('basicAuth');
this.loggedIn = false;
}
canActivate(route: ActivatedRouteSnapshot = null, state: RouterStateSnapshot = null): Observable<boolean> {
return new Observable<boolean>(observer => {
if (this.loggedIn === undefined) {
@ -60,4 +65,8 @@ export class LoginService implements CanActivate {
get isLoggedIn() {
return this.loggedIn;
}
get username() {
return atob(this.storage.get('basicAuth')).split(':')[0];
}
}