mirror of
https://github.com/dec0dOS/zero-ui.git
synced 2025-07-06 04:51:44 -07:00
refactor: squash commits
This commit is contained in:
parent
63ebcb5915
commit
1e6e237aa3
107 changed files with 20077 additions and 0 deletions
22
backend/routes/auth.js
Normal file
22
backend/routes/auth.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
const express = require("express");
|
||||
const router = express.Router();
|
||||
|
||||
const auth = require("../services/auth");
|
||||
|
||||
router.post("/login", async function (req, res) {
|
||||
if (req.body.username && req.body.password) {
|
||||
auth.authorize(req.body.username, req.body.password, function (err, user) {
|
||||
if (user) {
|
||||
res.send({ token: user["token"] });
|
||||
} else {
|
||||
res.status(401).send({
|
||||
error: err.message,
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
res.status(400).send({ error: "Specify username and password" });
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
Loading…
Add table
Add a link
Reference in a new issue