feat(authentication): Added idle-functionality to logout inactive users after a certain time of inactivity. (TV-535)
Squashed commit of the following:
commit ca11dd079dca884634ead2696899cfedbfc826f1
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date: Wed Nov 10 14:45:48 2021 +0100
Made changes after PR
commit a8a51ecdabf0d32aa67b814eee530c9a01d405a9
Merge: b1677aff 3b6ce438
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date: Wed Nov 10 12:47:54 2021 +0100
Merge branch 'develop' into feature/TV-535-idle-functionality
commit b1677aff5210288f4a86ba235dd1acb5d415f71f
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date: Wed Nov 10 09:17:55 2021 +0100
Added better check to avoid blank screens
commit 0129f3f6a1d4884d3f669b109bc9b8667fc6281c
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date: Wed Nov 10 09:12:55 2021 +0100
Added idle functionality
This commit is contained in:
@@ -15,20 +15,35 @@ export class AuthGuard implements CanActivate {
|
||||
return this.authenticationService.isLoggedIn$.pipe(
|
||||
switchMap(loggedIn => {
|
||||
if (loggedIn) {
|
||||
return of(true);
|
||||
return this.authenticationService.isTokenValid$.pipe(
|
||||
switchMap(({ isValid, isRefreshable }) => {
|
||||
if (isValid) {
|
||||
return of(true);
|
||||
}
|
||||
if (isRefreshable) {
|
||||
return this.authenticationService.refreshToken$();
|
||||
}
|
||||
this.redirectToLoginPage();
|
||||
return of(false);
|
||||
})
|
||||
);
|
||||
} else if (route.queryParams.code) {
|
||||
return this.authenticationService.login$(route.queryParams.code).pipe(map(result => !!result));
|
||||
}
|
||||
|
||||
void this.authenticationService.removeLocalStorageData();
|
||||
|
||||
if (environment.ciam.clientId) {
|
||||
document.location.href = `${environment.ciam.loginUrl}&client_id=${environment.ciam.clientId}&redirect_uri=${window.location.origin}`;
|
||||
} else {
|
||||
void this.router.navigateByUrl(environment.ciam.loginUrl);
|
||||
}
|
||||
this.redirectToLoginPage();
|
||||
return of(false);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
redirectToLoginPage(): void {
|
||||
this.authenticationService.removeLocalStorageData();
|
||||
|
||||
if (environment.ciam.clientId) {
|
||||
document.location.href = `${environment.ciam.loginUrl}&client_id=${environment.ciam.clientId}&redirect_uri=${window.location.origin}`;
|
||||
} else {
|
||||
void this.router.navigateByUrl(environment.ciam.loginUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user