refactor: squash commits

This commit is contained in:
dec0dOS 2021-03-21 22:25:13 +03:00
parent 63ebcb5915
commit 1e6e237aa3
107 changed files with 20077 additions and 0 deletions

22
backend/routes/auth.js Normal file
View 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;