aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/users.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-10-19 09:44:43 +0200
committerChocobozzz <me@florianbigard.com>2021-10-20 09:25:44 +0200
commit4beda9e12adc7b1f3b178cecd6863ebf3cf431f1 (patch)
tree6244a10b286d66c6dcd7799aee630670d0493781 /server/middlewares/validators/users.ts
parent9593a78ae1368a9ad8bb11044fce6fde2892701a (diff)
downloadPeerTube-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.ts22
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'
3import { omit } from 'lodash' 3import { omit } from 'lodash'
4import { Hooks } from '@server/lib/plugins/hooks' 4import { Hooks } from '@server/lib/plugins/hooks'
5import { MUserDefault } from '@server/types/models' 5import { MUserDefault } from '@server/types/models'
6import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' 6import { HttpStatusCode, UserRegister, UserRole } from '@shared/models'
7import { UserRole } from '../../../shared/models/users'
8import { UserRegister } from '../../../shared/models/users/user-register.model'
9import { toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc' 7import { toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc'
10import { isThemeNameValid } from '../../helpers/custom-validators/plugins' 8import { isThemeNameValid } from '../../helpers/custom-validators/plugins'
11import { 9import {
@@ -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
471const 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