mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
AAE-37746 logout on session_error during session checks
This commit is contained in:
@@ -273,6 +273,21 @@ describe('RedirectAuthService', () => {
|
||||
expect(oauthServiceSpy.logOut).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should logout user if sessionChecksEnabled is true and event type session_error is emitted', async () => {
|
||||
const mockTimeSync = { outOfSync: false } as TimeSync;
|
||||
timeSyncServiceSpy.checkTimeSync.and.returnValue(of(mockTimeSync));
|
||||
|
||||
ensureDiscoveryDocumentSpy.and.resolveTo(true);
|
||||
|
||||
authConfigSpy.sessionChecksEnabled = true;
|
||||
|
||||
await service.init();
|
||||
|
||||
oauthEvents$.next({ type: 'session_error' } as OAuthEvent);
|
||||
|
||||
expect(oauthServiceSpy.logOut).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should NOT logout user if login success', async () => {
|
||||
ensureDiscoveryDocumentSpy.and.resolveTo(true);
|
||||
|
||||
|
||||
@@ -339,7 +339,8 @@ export class RedirectAuthService extends AuthService {
|
||||
this.oauthService.tokenValidationHandler = new JwksValidationHandler();
|
||||
|
||||
if (config.sessionChecksEnabled) {
|
||||
this.oauthService.events.pipe(filter((event) => event.type === 'session_terminated')).subscribe(() => {
|
||||
const sessionErrorTypesToPerformLogout = ['session_terminated', 'session_error'];
|
||||
this.oauthService.events.pipe(filter((event) => sessionErrorTypesToPerformLogout.includes(event.type))).subscribe(() => {
|
||||
this.oauthService.logOut();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user