Skip to content

Commit

Permalink
Still working on the tutorial, added new steps
Browse files Browse the repository at this point in the history
  • Loading branch information
israelmuca committed Mar 4, 2019
1 parent 499963c commit 75b1792
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions controller/auth.controller.js
Expand Up @@ -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 })
}
Expand All @@ -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') })
}
5 changes: 3 additions & 2 deletions routes/auth.routes.js
@@ -1,14 +1,15 @@
import { validator } from '../validator/auth.validator'
import { procErr } from '../utilities/processErrors'
import { login,
forgotPassword } from '../controller/auth.controller'

// Routes =============================================================
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)

}

0 comments on commit 75b1792

Please sign in to comment.