diff options
author | Chocobozzz <me@florianbigard.com> | 2021-10-19 09:44:43 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-10-20 09:25:44 +0200 |
commit | 4beda9e12adc7b1f3b178cecd6863ebf3cf431f1 (patch) | |
tree | 6244a10b286d66c6dcd7799aee630670d0493781 /server/middlewares/validators/users.ts | |
parent | 9593a78ae1368a9ad8bb11044fce6fde2892701a (diff) | |
download | PeerTube-4beda9e12adc7b1f3b178cecd6863ebf3cf431f1.tar.gz PeerTube-4beda9e12adc7b1f3b178cecd6863ebf3cf431f1.tar.zst PeerTube-4beda9e12adc7b1f3b178cecd6863ebf3cf431f1.zip |
Add ability to view my followers
Diffstat (limited to 'server/middlewares/validators/users.ts')
-rw-r--r-- | server/middlewares/validators/users.ts | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index c06b85862..c6eeeaf18 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts | |||
@@ -3,9 +3,7 @@ import { body, param, query } from 'express-validator' | |||
3 | import { omit } from 'lodash' | 3 | import { omit } from 'lodash' |
4 | import { Hooks } from '@server/lib/plugins/hooks' | 4 | import { Hooks } from '@server/lib/plugins/hooks' |
5 | import { MUserDefault } from '@server/types/models' | 5 | import { MUserDefault } from '@server/types/models' |
6 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' | 6 | import { HttpStatusCode, UserRegister, UserRole } from '@shared/models' |
7 | import { UserRole } from '../../../shared/models/users' | ||
8 | import { UserRegister } from '../../../shared/models/users/user-register.model' | ||
9 | import { toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc' | 7 | import { toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc' |
10 | import { isThemeNameValid } from '../../helpers/custom-validators/plugins' | 8 | import { isThemeNameValid } from '../../helpers/custom-validators/plugins' |
11 | import { | 9 | import { |
@@ -462,7 +460,22 @@ const ensureAuthUserOwnsAccountValidator = [ | |||
462 | if (res.locals.account.id !== user.Account.id) { | 460 | if (res.locals.account.id !== user.Account.id) { |
463 | return res.fail({ | 461 | return res.fail({ |
464 | status: HttpStatusCode.FORBIDDEN_403, | 462 | status: HttpStatusCode.FORBIDDEN_403, |
465 | message: 'Only owner can access ratings list.' | 463 | message: 'Only owner of this account can access this ressource.' |
464 | }) | ||
465 | } | ||
466 | |||
467 | return next() | ||
468 | } | ||
469 | ] | ||
470 | |||
471 | const ensureAuthUserOwnsChannelValidator = [ | ||
472 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
473 | const user = res.locals.oauth.token.User | ||
474 | |||
475 | if (res.locals.videoChannel.Account.userId !== user.id) { | ||
476 | return res.fail({ | ||
477 | status: HttpStatusCode.FORBIDDEN_403, | ||
478 | message: 'Only owner of this video channel can access this ressource' | ||
466 | }) | 479 | }) |
467 | } | 480 | } |
468 | 481 | ||
@@ -506,6 +519,7 @@ export { | |||
506 | usersVerifyEmailValidator, | 519 | usersVerifyEmailValidator, |
507 | userAutocompleteValidator, | 520 | userAutocompleteValidator, |
508 | ensureAuthUserOwnsAccountValidator, | 521 | ensureAuthUserOwnsAccountValidator, |
522 | ensureAuthUserOwnsChannelValidator, | ||
509 | ensureCanManageUser | 523 | ensureCanManageUser |
510 | } | 524 | } |
511 | 525 | ||