[ACA-4322] Logout - Avoid the redirect in case SSO auth (#6780)

* Avoid the redirect in case of sso

* Move the code into the if
This commit is contained in:
Maurizio Vitale 2021-03-05 09:46:21 +00:00 committed by GitHub
parent a5eb5acf5d
commit c152df30ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 10 deletions

View File

@ -87,17 +87,16 @@ describe('LogoutDirective', () => {
expect(router.navigate).toHaveBeenCalledWith(['fake-base-logout']); expect(router.navigate).toHaveBeenCalledWith(['fake-base-logout']);
}); });
it('should redirect to redirectUriLogout on click if SSO auth', () => { it('should never redirect if SSO auth, because the redirect is done by the js-api', () => {
spyOn(router, 'navigate'); spyOn(router, 'navigate');
spyOn(authService, 'isOauth').and.returnValue(true); spyOn(authService, 'isOauth').and.returnValue(true);
spyOn(authService, 'logout').and.returnValue(of(true)); spyOn(authService, 'logout').and.returnValue(of(true));
appConfig.config['oauth2.redirectUriLogout'] = 'fake-logout';
const button = fixture.nativeElement.querySelector('button'); const button = fixture.nativeElement.querySelector('button');
button.click(); button.click();
expect(authService.logout).toHaveBeenCalled(); expect(authService.logout).toHaveBeenCalled();
expect(router.navigate).toHaveBeenCalledWith(['fake-logout']); expect(router.navigate).not.toHaveBeenCalled();
}); });
it('should redirect to login even on logout error', () => { it('should redirect to login even on logout error', () => {

View File

@ -52,11 +52,7 @@ export class LogoutDirective implements OnInit {
getRedirectUri () { getRedirectUri () {
if (this.redirectUri === undefined ) { if (this.redirectUri === undefined ) {
if (this.auth.isOauth()) { return this.appConfig.get<string>('loginRoute', '/login');
return this.appConfig.get<string>('oauth2.redirectUriLogout');
} else {
return this.appConfig.get<string>('loginRoute', '/login');
}
} }
return this.redirectUri; return this.redirectUri;
} }
@ -69,8 +65,8 @@ export class LogoutDirective implements OnInit {
} }
redirectToUri() { redirectToUri() {
const redirectRoute = this.getRedirectUri(); if (this.enableRedirect && !this.auth.isOauth()) {
if (this.enableRedirect) { const redirectRoute = this.getRedirectUri();
this.router.navigate([redirectRoute]); this.router.navigate([redirectRoute]);
} }
} }