[ACS-8961] Emit onLogout when redirected to login page (#10401)

* [ACS-8961] Emit onLogout when redirected to login page

* [ACS-8961] empty commit [ci:force]
This commit is contained in:
Mykyta Maliarchuk 2024-12-20 15:52:38 +01:00 committed by GitHub
parent e967f20cb6
commit dc7e5c2215
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View File

@ -171,6 +171,17 @@ describe('AuthGuardService', () => {
expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/login?redirectUrl=some-url')); expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/login?redirectUrl=some-url'));
}); });
it('should emit onLogout if the user is NOT logged in and basic authentication is used', async () => {
spyOn(authService, 'isLoggedIn').and.returnValue(false);
spyOn(authService, 'isOauth').and.returnValue(false);
appConfigService.config.loginRoute = 'login';
spyOn(basicAlfrescoAuthService.onLogout, 'next');
await TestBed.runInInjectionContext(() => AuthGuard(route, state));
expect(basicAlfrescoAuthService.onLogout.next).toHaveBeenCalledWith(true);
});
it('should set redirect url with query params', async () => { it('should set redirect url with query params', async () => {
state.url = 'some-url;q=query'; state.url = 'some-url;q=query';
appConfigService.config.loginRoute = 'login'; appConfigService.config.loginRoute = 'login';

View File

@ -67,12 +67,12 @@ export class AuthGuardService {
provider: this.getProvider(), provider: this.getProvider(),
url url
}); });
this.basicAlfrescoAuthService.onLogout.next(true);
urlToRedirect = `${urlToRedirect}?redirectUrl=${url}`; urlToRedirect = `${urlToRedirect}?redirectUrl=${url}`;
return this.navigate(urlToRedirect); return this.navigate(urlToRedirect);
} else if (this.getOauthConfig().silentLogin && !this.oidcAuthenticationService.isPublicUrl()) { } else if (this.getOauthConfig().silentLogin && !this.oidcAuthenticationService.isPublicUrl()) {
const shouldPerformSsoLogin = await new Promise((resolve) => { const shouldPerformSsoLogin = await new Promise((resolve) => {
this.oidcAuthenticationService.shouldPerformSsoLogin$.subscribe(value => resolve(value)); this.oidcAuthenticationService.shouldPerformSsoLogin$.subscribe((value) => resolve(value));
}); });
if (shouldPerformSsoLogin) { if (shouldPerformSsoLogin) {
this.oidcAuthenticationService.ssoLogin(url); this.oidcAuthenticationService.ssoLogin(url);