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