From c3608d0ab27ed73f6776b8a543847a2856407a84 Mon Sep 17 00:00:00 2001 From: Jonas Schmedtmann Date: Fri, 12 Jul 2019 17:41:54 +0100 Subject: [PATCH] Fixed signup bug --- 4-natours/after-section-10/controllers/authController.js | 8 +++++++- 4-natours/after-section-11/controllers/authController.js | 8 +++++++- 4-natours/after-section-12/controllers/authController.js | 8 +++++++- 4-natours/after-section-13/controllers/authController.js | 7 ++++++- 4-natours/after-section-14/controllers/authController.js | 7 ++++++- 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/4-natours/after-section-10/controllers/authController.js b/4-natours/after-section-10/controllers/authController.js index 77032b17c4..fcba5389ed 100644 --- a/4-natours/after-section-10/controllers/authController.js +++ b/4-natours/after-section-10/controllers/authController.js @@ -37,7 +37,13 @@ const createSendToken = (user, statusCode, res) => { }; exports.signup = catchAsync(async (req, res, next) => { - const newUser = await User.create(req.body); + const newUser = await User.create({ + name: req.body.name, + email: req.body.email, + password: req.body.password, + passwordConfirm: req.body.passwordConfirm + }); + createSendToken(newUser, 201, res); }); diff --git a/4-natours/after-section-11/controllers/authController.js b/4-natours/after-section-11/controllers/authController.js index 77032b17c4..fcba5389ed 100644 --- a/4-natours/after-section-11/controllers/authController.js +++ b/4-natours/after-section-11/controllers/authController.js @@ -37,7 +37,13 @@ const createSendToken = (user, statusCode, res) => { }; exports.signup = catchAsync(async (req, res, next) => { - const newUser = await User.create(req.body); + const newUser = await User.create({ + name: req.body.name, + email: req.body.email, + password: req.body.password, + passwordConfirm: req.body.passwordConfirm + }); + createSendToken(newUser, 201, res); }); diff --git a/4-natours/after-section-12/controllers/authController.js b/4-natours/after-section-12/controllers/authController.js index 506e177bf9..1999567ddd 100644 --- a/4-natours/after-section-12/controllers/authController.js +++ b/4-natours/after-section-12/controllers/authController.js @@ -37,7 +37,13 @@ const createSendToken = (user, statusCode, res) => { }; exports.signup = catchAsync(async (req, res, next) => { - const newUser = await User.create(req.body); + const newUser = await User.create({ + name: req.body.name, + email: req.body.email, + password: req.body.password, + passwordConfirm: req.body.passwordConfirm + }); + createSendToken(newUser, 201, res); }); diff --git a/4-natours/after-section-13/controllers/authController.js b/4-natours/after-section-13/controllers/authController.js index b190aac8f1..c508bbda0a 100644 --- a/4-natours/after-section-13/controllers/authController.js +++ b/4-natours/after-section-13/controllers/authController.js @@ -37,7 +37,12 @@ const createSendToken = (user, statusCode, res) => { }; exports.signup = catchAsync(async (req, res, next) => { - const newUser = await User.create(req.body); + const newUser = await User.create({ + name: req.body.name, + email: req.body.email, + password: req.body.password, + passwordConfirm: req.body.passwordConfirm + }); const url = `${req.protocol}://${req.get('host')}/me`; console.log(url); diff --git a/4-natours/after-section-14/controllers/authController.js b/4-natours/after-section-14/controllers/authController.js index f5f89f3f8a..d4f99b50b0 100644 --- a/4-natours/after-section-14/controllers/authController.js +++ b/4-natours/after-section-14/controllers/authController.js @@ -36,7 +36,12 @@ const createSendToken = (user, statusCode, req, res) => { }; exports.signup = catchAsync(async (req, res, next) => { - const newUser = await User.create(req.body); + const newUser = await User.create({ + name: req.body.name, + email: req.body.email, + password: req.body.password, + passwordConfirm: req.body.passwordConfirm + }); const url = `${req.protocol}://${req.get('host')}/me`; // console.log(url);