2025-03-31 17:00:28 +02:00
|
|
|
const handleError = require("../middleware/errors");
|
|
|
|
const authService = require("../services/authService");
|
|
|
|
|
|
|
|
async function login(req, res) {
|
|
|
|
try {
|
2025-05-04 23:14:00 +02:00
|
|
|
const username = req.body.username;
|
|
|
|
const email = req.body.email;
|
|
|
|
const password = req.body.password
|
|
|
|
const token = await authService.login(username, email, password);
|
2025-03-31 17:00:28 +02:00
|
|
|
res.json({ token });
|
|
|
|
} catch (err) {
|
2025-05-04 19:31:03 +02:00
|
|
|
handleError(err, res);
|
2025-03-31 17:00:28 +02:00
|
|
|
}
|
|
|
|
|
2025-05-04 23:14:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { login };
|