This commit is contained in:
parent
13aa2c29b0
commit
8d6129590a
|
@ -17,8 +17,20 @@ export class HomeComponent implements OnInit {
|
|||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
// TODO: First try to read existing session data
|
||||
this.authenticateUser();
|
||||
if(!HomeComponent.sessionDataAvailable()) {
|
||||
this.authenticateUser();
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there is session data saved in the local storage
|
||||
* @return If there is session data available
|
||||
*/
|
||||
private static sessionDataAvailable(): boolean {
|
||||
let user = StorageService.getUserInfo();
|
||||
|
||||
return user !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,6 +47,10 @@ export class HomeComponent implements OnInit {
|
|||
sessionKey: ''
|
||||
};
|
||||
|
||||
if(user.firebonkId === undefined || user.firstName === undefined || user.token === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
let authenticatedUser = ApiService.performAuthentication(user);
|
||||
StorageService.setUserInfo(authenticatedUser);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user