1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | import * as express from "express";
|
7 | import Role from "./entities/role.entity";
|
8 | import Request from "./request";
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | export function authUser(req: Request, _: express.Response) {
|
14 | if (!req.user || req.user === undefined) {
|
15 | return false;
|
16 | }
|
17 | return true;
|
18 | }
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | export function notAuthUser(req: Request, res: express.Response) {
|
24 | return !authUser(req, res);
|
25 | }
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | export function isStaffOrGreater(req: Request, res: express.Response) {
|
31 | if (!authUser(req, res)) {
|
32 | return false;
|
33 | }
|
34 | if (req.user.level >= Role.STAFF_LEVEL) {
|
35 | return true;
|
36 | }
|
37 | return false;
|
38 | }
|