From 0e76f4563a45ad98d424d2769f0c9e5d2a427d48 Mon Sep 17 00:00:00 2001 From: Sebastian Leidig Date: Mon, 25 Nov 2024 15:46:34 +0100 Subject: [PATCH] fix special cases with unlinked/broken user entity --- .../session-manager.service.spec.ts | 20 +------------------ .../session-manager.service.ts | 1 + 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/src/app/core/session/session-service/session-manager.service.spec.ts b/src/app/core/session/session-service/session-manager.service.spec.ts index 8f0afa19df..8337f9afe8 100644 --- a/src/app/core/session/session-service/session-manager.service.spec.ts +++ b/src/app/core/session/session-service/session-manager.service.spec.ts @@ -1,20 +1,3 @@ -/* - * This file is part of ndb-core. - * - * ndb-core is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ndb-core is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ndb-core. If not, see . - */ - import { SessionManagerService } from "./session-manager.service"; import { LoginState } from "../session-states/login-state.enum"; import { @@ -152,7 +135,6 @@ describe("SessionManagerService", () => { entityId: adminUser.getId(), }); await service.remoteLogin(); - expect(currentUser.value).toBeUndefined(); // user entity available -> user should be set await entityMapper.save(adminUser); @@ -171,7 +153,7 @@ describe("SessionManagerService", () => { expect(loadSpy).not.toHaveBeenCalled(); expect(loginStateSubject.value).toBe(LoginState.LOGGED_IN); - expect(TestBed.inject(CurrentUserSubject).value).toBeUndefined(); + expect(TestBed.inject(CurrentUserSubject).value).toBeNull(); }); it("should allow other entities to log in", async () => { diff --git a/src/app/core/session/session-service/session-manager.service.ts b/src/app/core/session/session-service/session-manager.service.ts index 689507cd78..7ddcd18f35 100644 --- a/src/app/core/session/session-service/session-manager.service.ts +++ b/src/app/core/session/session-service/session-manager.service.ts @@ -110,6 +110,7 @@ export class SessionManagerService { private initUserEntity(entityId: string) { if (!entityId) { this.currentUser.next(null); + return; } const entityType = Entity.extractTypeFromId(entityId);