diff options
Diffstat (limited to 'server/middlewares/user-right.ts')
-rw-r--r-- | server/middlewares/user-right.ts | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/server/middlewares/user-right.ts b/server/middlewares/user-right.ts deleted file mode 100644 index 7d53e8341..000000000 --- a/server/middlewares/user-right.ts +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | import express from 'express' | ||
2 | import { HttpStatusCode, UserRight } from '@shared/models' | ||
3 | import { logger } from '../helpers/logger' | ||
4 | |||
5 | function ensureUserHasRight (userRight: UserRight) { | ||
6 | return function (req: express.Request, res: express.Response, next: express.NextFunction) { | ||
7 | const user = res.locals.oauth.token.user | ||
8 | if (user.hasRight(userRight) === false) { | ||
9 | const message = `User ${user.username} does not have right ${userRight} to access to ${req.path}.` | ||
10 | logger.info(message) | ||
11 | |||
12 | return res.fail({ | ||
13 | status: HttpStatusCode.FORBIDDEN_403, | ||
14 | message | ||
15 | }) | ||
16 | } | ||
17 | |||
18 | return next() | ||
19 | } | ||
20 | } | ||
21 | |||
22 | // --------------------------------------------------------------------------- | ||
23 | |||
24 | export { | ||
25 | ensureUserHasRight | ||
26 | } | ||