diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-12 17:53:50 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-13 16:50:33 +0100 |
commit | 3fd3ab2d34d512b160a5e6084d7609be7b4f4452 (patch) | |
tree | e5ca358287fca6ecacce83defcf23af1e8e9f419 /server/middlewares/user-right.ts | |
parent | c893d4514e6ecbf282c7985fe5f82b8acd8a1137 (diff) | |
download | PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.tar.gz PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.tar.zst PeerTube-3fd3ab2d34d512b160a5e6084d7609be7b4f4452.zip |
Move models to typescript-sequelize
Diffstat (limited to 'server/middlewares/user-right.ts')
-rw-r--r-- | server/middlewares/user-right.ts | 7 |
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 @@ | |||
1 | import 'express-validator' | ||
2 | import * as express from 'express' | 1 | import * as express from 'express' |
3 | 2 | import 'express-validator' | |
4 | import { UserInstance } from '../models' | ||
5 | import { UserRight } from '../../shared' | 3 | import { UserRight } from '../../shared' |
6 | import { logger } from '../helpers' | 4 | import { logger } from '../helpers' |
5 | import { UserModel } from '../models/account/user' | ||
7 | 6 | ||
8 | function ensureUserHasRight (userRight: UserRight) { | 7 | function 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) |