Add logout event handler
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Willem Dantuma 2020-06-25 17:21:12 +02:00
parent b3d0a6f0c7
commit f89209c555

View File

@ -14,10 +14,10 @@ export function appConfigFactory(injector:Injector, appConfig: AppConfig, oauthS
appConfig.load().then(() => { appConfig.load().then(() => {
oauthService.events.subscribe((event) => { oauthService.events.subscribe((event) => {
console.debug(event.type); console.debug(event.type);
if (event.type == 'token_error' || event.type == 'silent_refresh_timeout') { if (event.type == 'token_error' || event.type == 'silent_refresh_timeout' || event.type == 'logout') {
let e = event as OAuthErrorEvent; let e = event as OAuthErrorEvent;
let p = e.params as any; let p = e.params as any;
if (event.type == 'silent_refresh_timeout' || (p.error && p.error == 'login_required')) { if (event.type == 'silent_refresh_timeout' || event.type == 'logout' || (p.error && p.error == 'login_required')) {
let router = injector.get(Router); let router = injector.get(Router);
console.debug("Session expired"); console.debug("Session expired");
router.navigate(['loggedout'], { queryParams: { redirectTo: router.url } }); router.navigate(['loggedout'], { queryParams: { redirectTo: router.url } });