Fixing user info reading at page load
Jenkins Production Deployment Details

This commit is contained in:
Patrick Müller 2022-09-26 17:59:36 +02:00
parent 13aa2c29b0
commit 8d6129590a
Signed by: Paddy
GPG Key ID: 37ABC11275CAABCE
1 changed files with 18 additions and 2 deletions

View File

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