Atualizado

This commit is contained in:
Luiz F Picolo 2024-10-31 21:14:41 -04:00
parent ba01ec046a
commit a3cacc8a3e
3 changed files with 15 additions and 3 deletions

View File

@ -4,4 +4,15 @@ const autenticar = function(req, res){
}) })
} }
module.exports = { autenticar } 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 }

View File

@ -1,8 +1,9 @@
var express = require('express'); var express = require('express');
var router = express.Router(); var router = express.Router();
const { autenticar } = require('../controllers/autenticarController') const { autenticar, validarUsuario } = require('../controllers/autenticarController')
/* GET home page. */ /* GET home page. */
router.get('/', autenticar); router.get('/', autenticar);
router.post('/validar-usuario', validarUsuario);
module.exports = router; module.exports = router;

View File

@ -8,7 +8,7 @@
</head> </head>
<body> <body>
<h1>Autenticar</h1> <h1>Autenticar</h1>
<form action="" method="post"> <form action="/autenticar/validar-usuario" method="post">
<label for="">Usuario</label> <label for="">Usuario</label>
<input type="text" name="usuario" id=""> <input type="text" name="usuario" id="">
<label for="">Senha</label> <label for="">Senha</label>