Add super admin user management
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m46s

This commit is contained in:
Cauê Faleiros
2026-06-16 15:46:04 -03:00
parent f811d3c0ab
commit c8d475808b
12 changed files with 1126 additions and 34 deletions

View File

@@ -3,16 +3,21 @@ const { login } = require('../auth');
const router = express.Router();
router.post('/login', (req, res) => {
router.post('/login', async (req, res, next) => {
const { email, password } = req.body;
const token = login(email, password);
if (!token) {
res.status(401).json({ error: 'Invalid credentials' });
return;
try {
const authResult = await login(email, password);
if (!authResult) {
res.status(401).json({ error: 'Invalid credentials' });
return;
}
res.json(authResult);
} catch (error) {
next(error);
}
res.json({ token });
});
module.exports = router;