Skip to content

Commit 67335e2

Browse files
committed
refactor: simplify email validation by using verifyUniqueEmail function
1 parent 7cf07dc commit 67335e2

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import { client } from "@/lib/utils";
1+
import { verifyUniqueEmail } from "./user.service";
22

33
// Se mantiene para hacer la validación de correo electrónico en el registro del lado del cliente
44
export async function findEmail(email: string): Promise<boolean> {
5-
const body = await client<boolean>("/users/findEmail", {
6-
body: { email },
7-
});
8-
9-
return body;
5+
return verifyUniqueEmail(email);
106
}

src/services/user.service.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,11 @@ export async function getOrCreateUser(email: string): Promise<User> {
4848

4949
return existingUser;
5050
}
51+
52+
export async function verifyUniqueEmail(email: string): Promise<boolean> {
53+
const user = await prisma.user.findUnique({
54+
where: { email },
55+
});
56+
57+
return user ? true : false;
58+
}

0 commit comments

Comments
 (0)