Skip to content

Commit d9eeae0

Browse files
author
Andrea Barbasso
committed
[CST-2710] avoid using empty user value as valid user
1 parent 3c08aa1 commit d9eeae0

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

src/app/accessibility/accessibility-settings.service.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ describe('accessibilitySettingsService', () => {
286286

287287
it('should store settings in metadata when the user is authenticated', fakeAsync(() => {
288288
const user = new EPerson();
289+
user._links = { self: { href: 'https://rest.api/eperson/123' }, groups: { href: 'https://rest.api/eperson/123/groups' } };
289290
authService.getAuthenticatedUserFromStoreIfAuthenticated = jasmine.createSpy().and.returnValue(of(user));
290291

291292
service.setSettingsInAuthenticatedUserMetadata({}).subscribe();

src/app/accessibility/accessibility-settings.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export class AccessibilitySettingsService {
204204
return this.authService.getAuthenticatedUserFromStoreIfAuthenticated().pipe(
205205
take(1),
206206
switchMap(user => {
207-
if (hasValue(user)) {
207+
if (hasValue(user) && hasValue(user._links?.self)) {
208208
// EPerson has to be cloned, otherwise the EPerson's metadata can't be modified
209209
const clonedUser = cloneDeep(user);
210210
return this.setSettingsInMetadata(clonedUser, settings);

0 commit comments

Comments
 (0)