From 9063b30d381491bdb59c4b21f0aca6469217d39c Mon Sep 17 00:00:00 2001 From: MohammadHMazarei Date: Mon, 23 Dec 2024 22:18:42 +0330 Subject: [PATCH] ADD: signup handler --- components/user/userController.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/user/userController.js b/components/user/userController.js index 0af2808..47ecb6f 100644 --- a/components/user/userController.js +++ b/components/user/userController.js @@ -2,6 +2,17 @@ const catchAsync = require('../../globalErrorHandler/catchAsync') const userService = require('./userService') +exports.signup = catchAsync(async (req, res, next) => { + const { user, token, cookieOptions } = await userService.signup( + req.body.name, + req.body.email, + req.body.password, + req.body.passwordConfirm + ) + res.cookie('jwt', token, cookieOptions) + res.status(200).json({ status: 'success ', data: { user, token } }) +}) + exports.loginUser = catchAsync(async (req, res, next) => { const user = await userService.loginUser(req.body.rawPassword) const maxAge = 60 * 60 * 24 * 90