Skip to content

Commit cd37f34

Browse files
Andrea Barbassovins01-4science
authored andcommitted
Merged in task/dspace-cris-2025_02_x/DSC-2710 (pull request DSpace#4069)
[CST-2710] avoid using empty user value as valid user Approved-by: Francesco Molinaro
2 parents edbde77 + d9eeae0 commit cd37f34

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

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

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

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

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ export class AccessibilitySettingsService {
213213
return this.authService.getAuthenticatedUserFromStoreIfAuthenticated().pipe(
214214
take(1),
215215
switchMap(user => {
216-
if (hasValue(user)) {
216+
if (hasValue(user) && hasValue(user._links?.self)) {
217217
// EPerson has to be cloned, otherwise the EPerson's metadata can't be modified
218218
const clonedUser = cloneDeep(user);
219219
return this.setSettingsInMetadata(clonedUser, settings);

0 commit comments

Comments
 (0)