diff --git a/src/controller/auth.ts b/src/controller/auth.ts index 89fc302..60ce275 100644 --- a/src/controller/auth.ts +++ b/src/controller/auth.ts @@ -100,24 +100,23 @@ const postSignupController = async (req: Request, res: Response) => { const postLoginController = async (req: Request, res: Response) => { try { - const { email, password } = req.body; - const data = await authService.postLoginService(email, password); + const resData = await authService.postLoginService(req.body); - if (data === -1) { + if (resData === constant.NULL_VALUE) { response.basicResponse( res, returnCode.BAD_REQUEST, false, "필요한 값이 없습니다." ); - } else if (data === -2) { + } else if (resData === -100) { response.basicResponse( res, returnCode.NOT_FOUND, false, "존재하지 않는 이메일입니다." ); - } else if (data === -3) { + } else if (resData === -101) { response.basicResponse( res, returnCode.BAD_REQUEST, @@ -125,13 +124,12 @@ const postLoginController = async (req: Request, res: Response) => { "비밀번호가 일치하지 않습니다." ); } else { - const { nickname, token } = data; response.dataResponse( res, returnCode.OK, "장서현의 첫 api 소중히 다뤄주세요 💋", true, - data + resData ); } } catch (err) { @@ -146,7 +144,7 @@ const postLoginController = async (req: Request, res: Response) => { } }; const authController = { - postSignupController, + postSignupController, postLoginController, }; diff --git a/src/service/auth.ts b/src/service/auth.ts index e249a6d..594addd 100644 --- a/src/service/auth.ts +++ b/src/service/auth.ts @@ -97,22 +97,22 @@ const postSignupService = async ({ email, nickname, password }) => { * @access public */ -const postLoginService = async (email: string, password: string) => { +const postLoginService = async ({ email, password }) => { // 요청 바디 부족 if (!email || !password) { - return -1; + return constant.NULL_VALUE; } // 존재하지 않는 이메일 const user = await User.findOne({ where: { email: email } }); if (!user) { - return -2; + return -100; } // 비밀번호 일치 X const isMatch = await bcrypt.compare(password, user.password); if (!isMatch) { - return -3; + return -101; } // 성공 시