Skip to content
Snippets Groups Projects
Commit d8de72a7 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #13695 TIME 1 fix sso logout redirect

parent 2bbf4eff
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,7 @@ export class LoginComponent implements OnInit {
});
this.environment = environment;
if (this.authService.isAuth()) {
if (this.authService.getToken() !== null) {
if (!this.functionsService.empty(this.authService.getUrl(JSON.parse(atob(this.authService.getToken().split('.')[1])).user.id))) {
this.router.navigate([this.authService.getUrl(JSON.parse(atob(this.authService.getToken().split('.')[1])).user.id)]);
} else {
......
......@@ -35,7 +35,7 @@ export class AppLightGuard implements CanActivate {
this.headerService.resetSideNavSelection();
return this.authService.getLoginInformations(state.url).pipe(
exhaustMap(() => this.authService.getToken() !== null ? this.authService.getCurrentUserInfo() : of(false)),
exhaustMap(() => this.authService.getToken() !== null && state.url !== '/login' ? this.authService.getCurrentUserInfo() : of(false)),
map(() => true),
catchError((err: any) => {
return of(true);
......
......@@ -38,7 +38,7 @@ export class AppGuard implements CanActivate {
} else if (this.authService.getToken() === null) {
this.authService.setCachedUrl(state.url.replace(/^\//g, ''));
console.debug('Aucun token trouvé ! Redirection sur login ...');
this.authService.logout(false);
this.authService.logout(false, true);
return false;
}
}),
......
......@@ -12,33 +12,33 @@ export class AuthInterceptor implements HttpInterceptor {
byPassToken: any[] = [
{
route: '../rest/prerequisites',
method : ['GET']
method: ['GET']
},
{
route: '../rest/authenticate',
method : ['POST']
method: ['POST']
},
{
route: '../rest/authenticate/token',
method : ['GET']
method: ['GET']
},
{
route: '../rest/authenticationInformation',
method : ['GET']
method: ['GET']
},
{
route: '../rest/passwordRules',
method : ['GET']
method: ['GET']
},
{
route: '../rest/languages',
method : ['GET']
method: ['GET']
}
];
byPassHandleErrors: any[] = [
{
route: '/password',
method : ['PUT']
method: ['PUT']
}
];
constructor(
......@@ -61,7 +61,7 @@ export class AuthInterceptor implements HttpInterceptor {
}
logout() {
this.authService.logout(false);
this.authService.logout(false, true);
this.notificationService.error(this.translate.instant('lang.sessionExpired'));
}
......@@ -105,12 +105,7 @@ export class AuthInterceptor implements HttpInterceptor {
catchError(err => {
// Disconnect user if bad token process
if (err.status === 401) {
if (this.router.url !== '/login' && this.router.url !== '/') {
this.logout();
} else {
return next.handle(request);
}
this.logout();
return of(false);
}
})
......@@ -120,12 +115,8 @@ export class AuthInterceptor implements HttpInterceptor {
catchError(err => {
// Disconnect user if bad token process
if (err.status === 401) {
console.debug('Refresh token failed !', request.url);
if (this.router.url !== '/login' && this.router.url !== '/') {
this.logout();
} else {
return next.handle(request);
}
console.debug('Refresh token failed !', request.url, this.router.url);
this.logout();
}
return of(false);
})
......
......@@ -102,8 +102,8 @@ export class AuthService {
this.localStorage.remove('MaarchCourrierRefreshToken');
}
async logout(cleanUrl: boolean = true) {
if (['cas', 'keycloak'].indexOf(this.authMode) > -1) {
async logout(cleanUrl: boolean = true, forcePageLogin: boolean = false) {
if (['cas', 'keycloak'].indexOf(this.authMode) > -1 && !forcePageLogin) {
this.SsoLogout(cleanUrl);
} else {
this.redirectAfterLogout(cleanUrl);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment