diff --git a/controllers/autenticarController.js b/controllers/autenticarController.js index 384b390..75ff9a3 100644 --- a/controllers/autenticarController.js +++ b/controllers/autenticarController.js @@ -4,4 +4,15 @@ const autenticar = function(req, res){ }) } -module.exports = { autenticar } \ No newline at end of file +const validarUsuario = function(req, res){ + if (req.body.usuario == 'Picolo' && req.body.senha == '123'){ + res.redirect('/') + } else { + res.status(400).send( + { error: "Usuário não existe" } + ); + } +} + +module.exports = { autenticar, validarUsuario } + diff --git a/routes/autenticar.js b/routes/autenticar.js index 79a9079..a9e39b8 100644 --- a/routes/autenticar.js +++ b/routes/autenticar.js @@ -1,8 +1,9 @@ var express = require('express'); var router = express.Router(); -const { autenticar } = require('../controllers/autenticarController') +const { autenticar, validarUsuario } = require('../controllers/autenticarController') /* GET home page. */ router.get('/', autenticar); +router.post('/validar-usuario', validarUsuario); module.exports = router; diff --git a/views/autenticar/index.ejs b/views/autenticar/index.ejs index e5b7369..23f8fb8 100644 --- a/views/autenticar/index.ejs +++ b/views/autenticar/index.ejs @@ -8,7 +8,7 @@

Autenticar

-
+