From 75b179241c79acf077fa27435e65d4d330bf893f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Israel=20Mu=C3=B1oz?= Date: Sun, 3 Mar 2019 21:06:51 -0600 Subject: [PATCH] Still working on the tutorial, added new steps --- controller/auth.controller.js | 4 ++++ routes/auth.routes.js | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/controller/auth.controller.js b/controller/auth.controller.js index f1d4622..4a83cd0 100644 --- a/controller/auth.controller.js +++ b/controller/auth.controller.js @@ -10,6 +10,8 @@ exports.login = (req, res) => { // If no validation errors, get the req.body objects that were validated and are needed const { email, password } = req.body + // Here, we would make use of that data, validating it against our database, creating a JWT token, etc... + // Since all the validations passed, we send the loginSuccessful message, which would normally include a JWT or some other form of authorization return res.status(200).send({ auth: true, message: req.polyglot.t('loginSuccessful'), token: null }) } @@ -27,6 +29,8 @@ exports.forgotPassword = (req, res) => { // If no validation errors, get the req.body objects that were validated and are needed const { email } = req.body + // Here, we would make use of that data, validating it against our database, creating a JWT token, etc... + // Since all the validations passed, we send the emailSent message return res.status(200).send({ auth: true, message: req.polyglot.t('emailSent') }) } \ No newline at end of file diff --git a/routes/auth.routes.js b/routes/auth.routes.js index 079c2e9..638cf67 100644 --- a/routes/auth.routes.js +++ b/routes/auth.routes.js @@ -1,4 +1,5 @@ import { validator } from '../validator/auth.validator' +import { procErr } from '../utilities/processErrors' import { login, forgotPassword } from '../controller/auth.controller' @@ -6,9 +7,9 @@ import { login, module.exports = router => { // POST route to mock a login endpoint - router.post("/api/login", validator('login'), login) + router.post("/api/login", validator('login'), procErr, login) // POST route to mock a forgotten password endpoint - router.post("/api/forgot-password", validator('forgotPassword'), forgotPassword) + router.post("/api/forgot-password", validator('forgotPassword'), procErr, forgotPassword) } \ No newline at end of file