[DURACOM-309] fix issue after logging in

This commit is contained in:
Andrea Barbasso
2025-02-06 15:22:02 +01:00
committed by FrancescoMolinaro
parent bc3d3e4129
commit 79d03d0433
3 changed files with 33 additions and 5 deletions

View File

@@ -256,6 +256,16 @@ export class AuthService {
); );
} }
/**
* Returns the authenticated user id from the store
* @returns {User}
*/
public getAuthenticatedUserIdFromStore(): Observable<string> {
return this.store.pipe(
select(getAuthenticatedUserId),
);
}
/** /**
* Checks if token is present into browser storage and is valid. * Checks if token is present into browser storage and is valid.
*/ */

View File

@@ -229,13 +229,13 @@ export class BrowserOrejimeService extends OrejimeService {
* Return saved preferences stored in the orejime cookie * Return saved preferences stored in the orejime cookie
*/ */
getSavedPreferences(): Observable<any> { getSavedPreferences(): Observable<any> {
return this.getUser$().pipe( return this.getUserId$().pipe(
map((user: EPerson) => { map((userId: string) => {
let storageName; let storageName;
if (isEmpty(user)) { if (isEmpty(userId)) {
storageName = ANONYMOUS_STORAGE_NAME_OREJIME; storageName = ANONYMOUS_STORAGE_NAME_OREJIME;
} else { } else {
storageName = this.getStorageName(user.uuid); storageName = this.getStorageName(userId);
} }
return this.cookieService.get(storageName); return this.cookieService.get(storageName);
}), }),
@@ -258,6 +258,24 @@ export class BrowserOrejimeService extends OrejimeService {
} }
} }
/**
* Retrieves the currently logged in user id
* Returns undefined when no one is logged in
*/
private getUserId$() {
return this.authService.isAuthenticated()
.pipe(
take(1),
switchMap((loggedIn: boolean) => {
if (loggedIn) {
return this.authService.getAuthenticatedUserIdFromStore();
}
return observableOf(undefined);
}),
take(1),
);
}
/** /**
* Retrieves the currently logged in user * Retrieves the currently logged in user
* Returns undefined when no one is logged in * Returns undefined when no one is logged in

View File

@@ -111,7 +111,7 @@ const ePersonMock: EPerson = Object.assign(new EPerson(), {
uuid: '0a53a0f2-e168-4ed9-b4af-cba9a2d267ca', uuid: '0a53a0f2-e168-4ed9-b4af-cba9a2d267ca',
language: null, language: null,
value: value:
'{"authentication":true,"preferences":true,"acknowledgement":true,"google-analytics":true}', '{"authentication":true,"preferences":true,"acknowledgement":true,"google-analytics":true,"correlation-id":true}',
place: 0, place: 0,
authority: null, authority: null,
confidence: -1, confidence: -1,