aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/user-right.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/user-right.ts')
-rw-r--r--server/middlewares/user-right.ts7
1 files changed, 3 insertions, 4 deletions
diff --git a/server/middlewares/user-right.ts b/server/middlewares/user-right.ts
index bcebe9d7f..5d63ebaf4 100644
--- a/server/middlewares/user-right.ts
+++ b/server/middlewares/user-right.ts
@@ -1,13 +1,12 @@
1import 'express-validator'
2import * as express from 'express' 1import * as express from 'express'
3 2import 'express-validator'
4import { UserInstance } from '../models'
5import { UserRight } from '../../shared' 3import { UserRight } from '../../shared'
6import { logger } from '../helpers' 4import { logger } from '../helpers'
5import { UserModel } from '../models/account/user'
7 6
8function ensureUserHasRight (userRight: UserRight) { 7function ensureUserHasRight (userRight: UserRight) {
9 return function (req: express.Request, res: express.Response, next: express.NextFunction) { 8 return function (req: express.Request, res: express.Response, next: express.NextFunction) {
10 const user: UserInstance = res.locals.oauth.token.user 9 const user = res.locals.oauth.token.user as UserModel
11 if (user.hasRight(userRight) === false) { 10 if (user.hasRight(userRight) === false) {
12 logger.info('User %s does not have right %s to access to %s.', user.username, UserRight[userRight], req.path) 11 logger.info('User %s does not have right %s to access to %s.', user.username, UserRight[userRight], req.path)
13 return res.sendStatus(403) 12 return res.sendStatus(403)