diff --git a/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-users/oauth-client-users.controller.ts b/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-users/oauth-client-users.controller.ts index 9a24f04ffc..12345efa5f 100644 --- a/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-users/oauth-client-users.controller.ts +++ b/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-users/oauth-client-users.controller.ts @@ -76,11 +76,6 @@ export class OAuthClientUsersController { this.logger.log( `Creating user with data: ${JSON.stringify(body, null, 2)} for OAuth Client with ID ${oAuthClientId}` ); - const existingUser = await this.userRepository.findByEmail(body.email); - - if (existingUser) { - throw new BadRequestException("A user with the provided email already exists."); - } const client = await this.oauthRepository.getOAuthClient(oAuthClientId); const isPlatformManaged = true; diff --git a/apps/api/v2/src/modules/oauth-clients/services/oauth-clients-users.service.ts b/apps/api/v2/src/modules/oauth-clients/services/oauth-clients-users.service.ts index ec2753a95d..d4fd46fb5e 100644 --- a/apps/api/v2/src/modules/oauth-clients/services/oauth-clients-users.service.ts +++ b/apps/api/v2/src/modules/oauth-clients/services/oauth-clients-users.service.ts @@ -23,7 +23,7 @@ export class OAuthClientUsersService { isPlatformManaged: boolean, organizationId?: number ) { - const existsWithEmail = await this.userExistsWithEmail(oAuthClientId, body.email); + const existsWithEmail = await this.managedUserExistsWithEmail(oAuthClientId, body.email); if (existsWithEmail) { throw new BadRequestException("User with the provided e-mail already exists."); } @@ -73,7 +73,7 @@ export class OAuthClientUsersService { }; } - async userExistsWithEmail(oAuthClientId: string, email: string) { + async managedUserExistsWithEmail(oAuthClientId: string, email: string) { const oAuthEmail = this.getOAuthUserEmail(oAuthClientId, email); const user = await this.userRepository.findByEmail(oAuthEmail); return !!user;