RED-7756 - Missing redirect to login page when trying to access tenant without being logged-in

This commit is contained in:
Valentin Mihai 2023-10-13 20:00:10 +03:00
parent 99701c7cd2
commit ebac60b314
2 changed files with 7 additions and 5 deletions

View File

@ -43,9 +43,11 @@ export function ifLoggedIn(): AsyncGuard {
await licenseService.loadLicenses();
const token = await keycloakService.getToken();
const jwtToken = jwt_decode(token) as JwtToken;
const authTime = (jwtToken.auth_time || jwtToken.iat).toString();
localStorage.setItem('authTime', authTime);
if (token) {
const jwtToken = jwt_decode(token) as JwtToken;
const authTime = (jwtToken.auth_time || jwtToken.iat).toString();
localStorage.setItem('authTime', authTime);
}
}
const isLoggedIn = await keycloakService.isLoggedIn();

View File

@ -28,11 +28,11 @@ export class RouterHistoryService {
}
});
const ref = effect(async () => {
if (this._tenantsService.activeTenantId.length === 0) {
const token = await this._keycloakService.getToken();
if (this._tenantsService.activeTenantId.length === 0 || !token) {
return;
}
const token = await this._keycloakService.getToken();
const jwtToken = jwt_decode(token) as JwtToken;
const authTime = (jwtToken.auth_time || jwtToken.iat).toString();
const localStorageAuthTime = localStorage.getItem('authTime');