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.ts3
1 files changed, 1 insertions, 2 deletions
diff --git a/server/middlewares/user-right.ts b/server/middlewares/user-right.ts
index 7cea7aa1e..498e3d677 100644
--- a/server/middlewares/user-right.ts
+++ b/server/middlewares/user-right.ts
@@ -2,11 +2,10 @@ import * as express from 'express'
2import 'express-validator' 2import 'express-validator'
3import { UserRight } from '../../shared' 3import { UserRight } from '../../shared'
4import { logger } from '../helpers/logger' 4import { logger } from '../helpers/logger'
5import { UserModel } from '../models/account/user'
6 5
7function ensureUserHasRight (userRight: UserRight) { 6function ensureUserHasRight (userRight: UserRight) {
8 return function (req: express.Request, res: express.Response, next: express.NextFunction) { 7 return function (req: express.Request, res: express.Response, next: express.NextFunction) {
9 const user = res.locals.oauth.token.user as UserModel 8 const user = res.locals.oauth.token.user
10 if (user.hasRight(userRight) === false) { 9 if (user.hasRight(userRight) === false) {
11 const message = `User ${user.username} does not have right ${UserRight[userRight]} to access to ${req.path}.` 10 const message = `User ${user.username} does not have right ${UserRight[userRight]} to access to ${req.path}.`
12 logger.info(message) 11 logger.info(message)