diff options
Diffstat (limited to 'server/middlewares/user-right.ts')
-rw-r--r-- | server/middlewares/user-right.ts | 3 |
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' | |||
2 | import 'express-validator' | 2 | import 'express-validator' |
3 | import { UserRight } from '../../shared' | 3 | import { UserRight } from '../../shared' |
4 | import { logger } from '../helpers/logger' | 4 | import { logger } from '../helpers/logger' |
5 | import { UserModel } from '../models/account/user' | ||
6 | 5 | ||
7 | function ensureUserHasRight (userRight: UserRight) { | 6 | function 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) |