diff --git a/lib/core/src/lib/auth/guard/auth-guard.service.spec.ts b/lib/core/src/lib/auth/guard/auth-guard.service.spec.ts index 565f066330a..bea48fd1570 100644 --- a/lib/core/src/lib/auth/guard/auth-guard.service.spec.ts +++ b/lib/core/src/lib/auth/guard/auth-guard.service.spec.ts @@ -171,6 +171,17 @@ describe('AuthGuardService', () => { 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 () => { state.url = 'some-url;q=query'; appConfigService.config.loginRoute = 'login'; diff --git a/lib/core/src/lib/auth/guard/auth-guard.service.ts b/lib/core/src/lib/auth/guard/auth-guard.service.ts index 48962f08079..c8cabbfad74 100644 --- a/lib/core/src/lib/auth/guard/auth-guard.service.ts +++ b/lib/core/src/lib/auth/guard/auth-guard.service.ts @@ -67,12 +67,12 @@ export class AuthGuardService { provider: this.getProvider(), url }); - + this.basicAlfrescoAuthService.onLogout.next(true); urlToRedirect = `${urlToRedirect}?redirectUrl=${url}`; return this.navigate(urlToRedirect); } else if (this.getOauthConfig().silentLogin && !this.oidcAuthenticationService.isPublicUrl()) { const shouldPerformSsoLogin = await new Promise((resolve) => { - this.oidcAuthenticationService.shouldPerformSsoLogin$.subscribe(value => resolve(value)); + this.oidcAuthenticationService.shouldPerformSsoLogin$.subscribe((value) => resolve(value)); }); if (shouldPerformSsoLogin) { this.oidcAuthenticationService.ssoLogin(url);