Skip to content
Snippets Groups Projects
Commit 5765179d authored by Jan Zickermann's avatar Jan Zickermann
Browse files

OZG-4993 OZG-5213 Use distinct refresh tokens

parent 18bcae1d
Branches
Tags
No related merge requests found
......@@ -139,15 +139,14 @@ describe('AuthenticationService', () => {
describe('get refresh token', () => {
let refreshToken1 = createAuthRefreshToken();
let refreshToken2 = createAuthRefreshToken();
let refreshToken3 = createAuthRefreshToken();
beforeEach(() => {
oAuthService.getRefreshToken
.mockReturnValueOnce(refreshToken1)
.mockReturnValueOnce(refreshToken2)
.mockReturnValueOnce(refreshToken3);
.mockReturnValueOnce(refreshToken1)
.mockReturnValueOnce(refreshToken2);
});
it('should emit one refresh token at start and then for each token_received event', () => {
it('should emit one refresh token at start and then distinct for each token_received event', () => {
const events = cold('-a-a-b-|', {
a: {
type: 'token_received',
......@@ -158,10 +157,9 @@ describe('AuthenticationService', () => {
});
Object.defineProperty(oAuthService, 'events', { value: events });
const refreshTokens = cold('ia-b---|', {
i: refreshToken1,
a: refreshToken2,
b: refreshToken3,
const refreshTokens = cold('a--b---|', {
a: refreshToken1,
b: refreshToken2,
});
expect(service.getRefreshToken()).toBeObservable(refreshTokens);
});
......
......@@ -4,7 +4,7 @@ import { AuthConfig, OAuthService } from 'angular-oauth2-oidc';
import { JwksValidationHandler } from 'angular-oauth2-oidc-jwks';
import { UserProfileResource } from 'libs/user-profile-shared/src/lib/user-profile.model';
import { getUserNameInitials } from 'libs/user-profile-shared/src/lib/user-profile.util';
import { filter, from, map, Observable, startWith, switchMap } from 'rxjs';
import { distinct, filter, from, map, Observable, startWith, switchMap } from 'rxjs';
import KcAdminClient from '@keycloak/keycloak-admin-client';
@Injectable({ providedIn: 'root' })
......@@ -22,6 +22,7 @@ export class AuthenticationService {
filter((event) => event.type === 'token_received'),
startWith(true),
map(() => this.oAuthService.getRefreshToken()),
distinct()
);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment