Skip to content

Commit

Permalink
Merge pull request #1961 from jagipas/fix-issue-1954
Browse files Browse the repository at this point in the history
Fix issue #1954: Ensure CheckingAuthFinished event fires regardless of authentication state
  • Loading branch information
FabianGosebrink authored Jun 11, 2024
2 parents dfe5500 + 1297d9c commit 6f3fa8e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,28 @@ describe('CheckAuthService', () => {
]);
});
}));

it('fires CheckingAuth-Event on start and finished event on end if not authenticated', waitForAsync(() => {
const allConfigs = [
{ configId: 'configId1', authority: 'some-authority' },
];

spyOn(currentUrlService, 'getCurrentUrl').and.returnValue(
'http://localhost:4200'
);
spyOn(authStateService, 'areAuthStorageTokensValid').and.returnValue(
false
);

const fireEventSpy = spyOn(publicEventsService, 'fireEvent');

checkAuthService.checkAuth(allConfigs[0], allConfigs).subscribe(() => {
expect(fireEventSpy.calls.allArgs()).toEqual([
[EventTypes.CheckingAuth],
[EventTypes.CheckingAuthFinished],
]);
});
}));
});

describe('checkAuthIncludingServer', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,8 @@ export class CheckAuthService {
this.authStateService.setAuthenticatedAndFireEvent(allConfigs);
this.userService.publishUserDataIfExists(config, allConfigs);
}

this.publicEventsService.fireEvent(EventTypes.CheckingAuthFinished);
}
this.publicEventsService.fireEvent(EventTypes.CheckingAuthFinished);

const result: LoginResponse = {
isAuthenticated,
Expand Down

0 comments on commit 6f3fa8e

Please sign in to comment.