diff --git a/packages/core/types/src/auth/common/auth-identity.ts b/packages/core/types/src/auth/common/auth-identity.ts index 522b7204a2..912577a030 100644 --- a/packages/core/types/src/auth/common/auth-identity.ts +++ b/packages/core/types/src/auth/common/auth-identity.ts @@ -189,4 +189,6 @@ export interface FilterableAuthIdentityProps */ provider?: string } + + app_metadata?: Record } diff --git a/packages/modules/auth/integration-tests/__fixtures__/auth-identity/index.ts b/packages/modules/auth/integration-tests/__fixtures__/auth-identity/index.ts index 187d16edba..ffa4753d8b 100644 --- a/packages/modules/auth/integration-tests/__fixtures__/auth-identity/index.ts +++ b/packages/modules/auth/integration-tests/__fixtures__/auth-identity/index.ts @@ -12,6 +12,9 @@ export async function createAuthIdentities( provider: "manual", }, ], + app_metadata: { + user_id: "user-1", + }, }, { id: "test-id-1", diff --git a/packages/modules/auth/integration-tests/__tests__/auth-module-service/auth-identity.spec.ts b/packages/modules/auth/integration-tests/__tests__/auth-module-service/auth-identity.spec.ts index 613aa053a2..01bf778dee 100644 --- a/packages/modules/auth/integration-tests/__tests__/auth-module-service/auth-identity.spec.ts +++ b/packages/modules/auth/integration-tests/__tests__/auth-module-service/auth-identity.spec.ts @@ -67,6 +67,20 @@ moduleIntegrationTestRunner({ }), ]) }) + + it("should list authIdentities by meta data", async () => { + const authIdentities = await service.listAuthIdentities({ + app_metadata: { + user_id: "user-1", + }, + }) + + expect(authIdentities).toEqual([ + expect.objectContaining({ + id: "test-id", + }), + ]) + }) }) describe("listAndCountAuthIdentities", () => { @@ -226,7 +240,9 @@ moduleIntegrationTestRunner({ const [authIdentity] = await service.listAuthIdentities({ id: [id] }) expect(authIdentity).toEqual( expect.objectContaining({ - app_metadata: { email: "test@email.com" }, + app_metadata: expect.objectContaining({ + email: "test@email.com", + }), }) ) }) diff --git a/packages/modules/auth/src/services/auth-module.ts b/packages/modules/auth/src/services/auth-module.ts index e271c4d58d..ece708d87a 100644 --- a/packages/modules/auth/src/services/auth-module.ts +++ b/packages/modules/auth/src/services/auth-module.ts @@ -145,10 +145,8 @@ export default class AuthModuleService ) return await this.baseRepository_.serialize< - AuthTypes.ProviderIdentityDTO[] - >(providerIdentities, { - populate: true, - }) + AuthTypes.ProviderIdentityDTO | AuthTypes.ProviderIdentityDTO[] + >(providerIdentities) } async authenticate(