diff --git a/src/identity/identity.entity.ts b/src/identity/identity.entity.ts index 73d0964ee..529dd16e2 100644 --- a/src/identity/identity.entity.ts +++ b/src/identity/identity.entity.ts @@ -32,7 +32,7 @@ export class Identity { @ManyToOne((_) => User, (user) => user.identities, { onDelete: 'CASCADE', // This deletes the Identity, when the associated User is deleted }) - user: User; + user: Promise; /** * The ProviderType of the identity @@ -103,7 +103,7 @@ export class Identity { syncSource: boolean, ): Omit { const newIdentity = new Identity(); - newIdentity.user = user; + newIdentity.user = Promise.resolve(user); newIdentity.providerType = providerType; newIdentity.providerName = null; newIdentity.syncSource = syncSource; diff --git a/src/identity/identity.service.spec.ts b/src/identity/identity.service.spec.ts index c7c44ac41..c93b4b797 100644 --- a/src/identity/identity.service.spec.ts +++ b/src/identity/identity.service.spec.ts @@ -60,7 +60,7 @@ describe('IdentityService', () => { await checkPassword(password, identity.passwordHash ?? '').then( (result) => expect(result).toBeTruthy(), ); - expect(identity.user).toEqual(user); + expect(await identity.user).toEqual(user); }); }); @@ -83,7 +83,7 @@ describe('IdentityService', () => { await checkPassword(newPassword, identity.passwordHash ?? '').then( (result) => expect(result).toBeTruthy(), ); - expect(identity.user).toEqual(user); + expect(await identity.user).toEqual(user); }); it('fails, when user has no local identity', async () => { user.identities = Promise.resolve([]);