mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[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:
parent
a5eb5acf5d
commit
c152df30ab
@ -87,17 +87,16 @@ describe('LogoutDirective', () => {
|
||||
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(authService, 'isOauth').and.returnValue(true);
|
||||
spyOn(authService, 'logout').and.returnValue(of(true));
|
||||
appConfig.config['oauth2.redirectUriLogout'] = 'fake-logout';
|
||||
|
||||
const button = fixture.nativeElement.querySelector('button');
|
||||
button.click();
|
||||
|
||||
expect(authService.logout).toHaveBeenCalled();
|
||||
expect(router.navigate).toHaveBeenCalledWith(['fake-logout']);
|
||||
expect(router.navigate).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should redirect to login even on logout error', () => {
|
||||
|
@ -52,12 +52,8 @@ export class LogoutDirective implements OnInit {
|
||||
|
||||
getRedirectUri () {
|
||||
if (this.redirectUri === undefined ) {
|
||||
if (this.auth.isOauth()) {
|
||||
return this.appConfig.get<string>('oauth2.redirectUriLogout');
|
||||
} else {
|
||||
return this.appConfig.get<string>('loginRoute', '/login');
|
||||
}
|
||||
}
|
||||
return this.redirectUri;
|
||||
}
|
||||
|
||||
@ -69,8 +65,8 @@ export class LogoutDirective implements OnInit {
|
||||
}
|
||||
|
||||
redirectToUri() {
|
||||
if (this.enableRedirect && !this.auth.isOauth()) {
|
||||
const redirectRoute = this.getRedirectUri();
|
||||
if (this.enableRedirect) {
|
||||
this.router.navigate([redirectRoute]);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user