From e1846510cd8837bb60bc2d118481d5a5170c6d88 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Wed, 25 Sep 2024 19:53:45 +0530 Subject: [PATCH] feat: set raw:true --- server/src/routes/auth.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/src/routes/auth.ts b/server/src/routes/auth.ts index db42eb17..ddb77d40 100644 --- a/server/src/routes/auth.ts +++ b/server/src/routes/auth.ts @@ -39,9 +39,11 @@ router.post('/login', async (req, res) => { if (!email || !password) return res.status(400).send('Email and password are required') if (password.length < 6) return res.status(400).send('Password must be at least 6 characters') - let user = await User.findOne({ where: { email } }); + let user = await User.findOne({raw: true, where: { email } }); if (!user) return res.status(400).send('User does not exist'); + console.log('User found:', user.email, user.password); + const match = await comparePassword(password, user.password) if (!match) return res.status(400).send('Invalid email or password') @@ -57,6 +59,7 @@ router.post('/login', async (req, res) => { res.json(user) } catch (error: any) { res.status(400).send(`Could not login user - ${error.message}`) + console.log(`Could not login user - ${error}`) } })