Fixing user info reading at page load
All checks were successful
Jenkins Production Deployment

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

View File

@ -17,8 +17,20 @@ export class HomeComponent implements OnInit {
} }
ngOnInit(): void { ngOnInit(): void {
// TODO: First try to read existing session data if(!HomeComponent.sessionDataAvailable()) {
this.authenticateUser(); 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: '' sessionKey: ''
}; };
if(user.firebonkId === undefined || user.firstName === undefined || user.token === undefined) {
return;
}
let authenticatedUser = ApiService.performAuthentication(user); let authenticatedUser = ApiService.performAuthentication(user);
StorageService.setUserInfo(authenticatedUser); StorageService.setUserInfo(authenticatedUser);
}); });