fix: managed users check if exist (#14649)

This commit is contained in:
Morgan authored and GitHub committed 2024-04-18 18:09:56 +00:00
1 parent 480977c2b5
commit eeb0322ce1
2 files changed
+2 -7

No files matched your search

@@ -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;
@@ -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;