From 8f9a56ba505e9b42775701c113d6edff562a7e6e Mon Sep 17 00:00:00 2001 From: BolesWaheed Date: Sat, 14 Oct 2023 03:33:34 +0300 Subject: [PATCH] login test done --- server/src/services/auth.service.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/server/src/services/auth.service.ts b/server/src/services/auth.service.ts index c7526d4..48c5233 100644 --- a/server/src/services/auth.service.ts +++ b/server/src/services/auth.service.ts @@ -5,17 +5,21 @@ import { generateToken } from '../utils'; import Request from '../models/request.model'; import User from '../models/user.model'; const login = async (username: string, password: string) => { - console.log(username, password); + // console.log(username, password); if (!(username && password)) throw new HttpError(StatusCodes.BAD_REQUEST, 'Username and password are required'); const user = await userModel.findOne({ username: username }); if (!user) throw new HttpError(StatusCodes.NOT_FOUND, 'User not found'); - const isCorrect: Boolean = await user!.isCorrectPassword(password); + console.log(user.password); + console.log(password); + console.log(user.password === password); + const isCorrect: boolean = await user.isCorrectPassword(password); + console.log(isCorrect); if (!isCorrect) throw new HttpError(StatusCodes.UNAUTHORIZED, 'Incorrect password'); - const token = generateToken(user!._id, user!.role); + // const token = generateToken(user!._id, user!.role); return { status: StatusCodes.OK, - message: 'Login successful', - JWTToken: token + message: 'Login successful' + // JWTToken: token }; }; const logout = () => {