fix spaces
This commit is contained in:
parent
f83c5aa423
commit
135c772723
7 changed files with 331 additions and 339 deletions
|
@ -6,23 +6,24 @@ import {db, createUser} from "../types/db";
|
|||
const router: Router = express.Router();
|
||||
|
||||
const adminCheck: Middleware = (req: Request, res: Response, next: NextFunction) => {
|
||||
if (!req.user)
|
||||
return res.status(403).send("You are not authorized to perform this action");
|
||||
else {
|
||||
if (req.user.username != "admin")
|
||||
return res.status(403).send("You are not authorized to perform this action");
|
||||
next();
|
||||
}
|
||||
if (!req.user)
|
||||
return res.status(403).send("You are not authorized to perform this action");
|
||||
else {
|
||||
if (req.user.username != "admin")
|
||||
return res.status(403).send("You are not authorized to perform this action");
|
||||
}
|
||||
|
||||
next();
|
||||
}
|
||||
|
||||
router.get("/adduser", adminCheck, (req: Request, res: Response, next: NextFunction) => {
|
||||
res.locals.filter = null;
|
||||
res.render("adduser", { user: req.user });
|
||||
res.locals.filter = null;
|
||||
res.render("adduser", { user: req.user });
|
||||
});
|
||||
|
||||
router.post("/adduser", adminCheck, (req: Request, res: Response, next: NextFunction) => {
|
||||
createUser(req.body.username, req.body.password);
|
||||
res.redirect('/');
|
||||
createUser(req.body.username, req.body.password);
|
||||
res.redirect('/');
|
||||
});
|
||||
|
||||
export default router;
|
Loading…
Add table
Add a link
Reference in a new issue