All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m46s
24 lines
505 B
JavaScript
24 lines
505 B
JavaScript
const express = require('express');
|
|
const { login } = require('../auth');
|
|
|
|
const router = express.Router();
|
|
|
|
router.post('/login', async (req, res, next) => {
|
|
const { email, password } = req.body;
|
|
|
|
try {
|
|
const authResult = await login(email, password);
|
|
|
|
if (!authResult) {
|
|
res.status(401).json({ error: 'Invalid credentials' });
|
|
return;
|
|
}
|
|
|
|
res.json(authResult);
|
|
} catch (error) {
|
|
next(error);
|
|
}
|
|
});
|
|
|
|
module.exports = router;
|