ADD: signup handler
This commit is contained in:
@@ -2,6 +2,17 @@
|
|||||||
const catchAsync = require('../../globalErrorHandler/catchAsync')
|
const catchAsync = require('../../globalErrorHandler/catchAsync')
|
||||||
const userService = require('./userService')
|
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) => {
|
exports.loginUser = catchAsync(async (req, res, next) => {
|
||||||
const user = await userService.loginUser(req.body.rawPassword)
|
const user = await userService.loginUser(req.body.rawPassword)
|
||||||
const maxAge = 60 * 60 * 24 * 90
|
const maxAge = 60 * 60 * 24 * 90
|
||||||
|
|||||||
Reference in New Issue
Block a user