From 248e764963e2ae7cd70d7d7f82a4d7242ee596d9 Mon Sep 17 00:00:00 2001 From: Florian Sylvain Date: Sun, 29 Jan 2023 22:44:51 +0100 Subject: [PATCH] Small function refactor --- src/routers/session.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/routers/session.ts b/src/routers/session.ts index 7e00465..dca4ed6 100644 --- a/src/routers/session.ts +++ b/src/routers/session.ts @@ -42,12 +42,8 @@ async function createUser(email: string, password: string) { }) } -async function getUser(email: string): Promise { - return await prisma.user.findFirst({ - where: { - email: email - } - }) +async function getUserByEmail(email: string): Promise { + return await prisma.user.findFirst({ where: { email } }) } function parseLoginData(data: any): LoginData | undefined { @@ -66,7 +62,7 @@ export const userRouterPostLogin: RequestHandler = async (req, res) => { return; } - const user = await getUser(loginData.email) + const user = await getUserByEmail(loginData.email) if (await isUserValid(user, loginData) === false) { res.status(400).json({ message: 'Incorrect credentials.' }) return;