Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Moderators cannot act on private admin entities

Chocobozzz498bf26aa57c
diff --git a/packages/core-utils/src/users/user-role.ts b/packages/core-utils/src/users/user-role.ts
index 938dbbb503..0745497d94 100644
--- a/packages/core-utils/src/users/user-role.ts
+++ b/packages/core-utils/src/users/user-role.ts
@@ -28,7 +28,9 @@ const userRoleRights: { [id in UserRoleType]: UserRightType[] } = {
UserRight.SEE_ALL_COMMENTS,
UserRight.MANAGE_REGISTRATIONS,
UserRight.MANAGE_INSTANCE_WATCHED_WORDS,
- UserRight.MANAGE_INSTANCE_AUTO_TAGS
+ UserRight.MANAGE_INSTANCE_AUTO_TAGS,
+ UserRight.CHANGE_VIDEO_OWNERSHIP,
+ UserRight.CHANGE_CHANNEL_OWNERSHIP
],
[UserRole.USER]: []
diff --git a/packages/models/src/users/user-right.enum.ts b/packages/models/src/users/user-right.enum.ts
index b10d69f9f8..fb2724b6a0 100644
--- a/packages/models/src/users/user-right.enum.ts
+++ b/packages/models/src/users/user-right.enum.ts
@@ -55,7 +55,9 @@ export const UserRight = {
MANAGE_INSTANCE_WATCHED_WORDS: 32,
MANAGE_INSTANCE_AUTO_TAGS: 33,
- MANAGE_SERVER_BLOCKLIST_SUBSCRIPTIONS: 34
+ MANAGE_SERVER_BLOCKLIST_SUBSCRIPTIONS: 34,
+
+ CHANGE_CHANNEL_OWNERSHIP: 35
} as const
export type UserRightType = typeof UserRight[keyof typeof UserRight]
diff --git a/packages/server-commands/src/search/search-command.ts b/packages/server-commands/src/search/search-command.ts
index 48e3744671..58f616287f 100644
--- a/packages/server-commands/src/search/search-command.ts
+++ b/packages/server-commands/src/search/search-command.ts
@@ -75,6 +75,7 @@ export class SearchCommand extends AbstractCommand {
options: OverrideCommandOptions & {
search?: string
sort?: string
+ videoPassword?: string
}
) {
const { search, sort } = options
@@ -92,9 +93,10 @@ export class SearchCommand extends AbstractCommand {
advancedVideoSearch (
options: OverrideCommandOptions & {
search?: VideosSearchQuery
+ videoPassword?: string
}
) {
- const { search } = options
+ const { search, videoPassword } = options
const path = '/api/v1/search/videos'
return this.getRequestBody<ResultList<Video>>({
@@ -102,6 +104,7 @@ export class SearchCommand extends AbstractCommand {
path,
query: search,
+ headers: this.buildVideoPasswordHeader(videoPassword),
implicitToken: false,
defaultExpectedStatus: HttpStatusCode.OK_200
})
diff --git a/packages/tests/src/api/check-params/channel-change-ownership.ts b/packages/tests/src/api/check-params/channel-change-ownership.ts
index bff452a827..ba6b3ddc3c 100644
--- a/packages/tests/src/api/check-params/channel-change-ownership.ts
+++ b/packages/tests/src/api/check-params/channel-change-ownership.ts
@@ -1,6 +1,6 @@
/* oxlint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import { ChangeOwnershipState, HttpStatusCode } from '@peertube/peertube-models'
+import { ChangeOwnershipState, HttpStatusCode, UserRole } from '@peertube/peertube-models'
import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@peertube/peertube-server-commands'
import { checkBadCountPagination, checkBadSort, checkBadStartPagination } from '@tests/shared/checks.js'
import { expect } from 'chai'
@@ -11,6 +11,7 @@ describe('Test channel change ownership API validator', function () {
let anotherUserToken: string
let rootEditorToken: string
let userEditorToken: string
+ let moderatorToken: string
let ownershipChangeId: number
// ---------------------------------------------------------------
@@ -29,6 +30,7 @@ describe('Test channel change ownership API validator', function () {
anotherUserToken = await server.users.generateUserAndToken('another_user')
rootEditorToken = await server.channelCollaborators.createEditor('root_editor', 'root_channel_1')
userEditorToken = await server.channelCollaborators.createEditor('user_editor', 'user_channel')
+ moderatorToken = await server.users.generateUserAndToken('moderator', UserRole.MODERATOR)
})
describe('Create channel ownership change request', function () {
@@ -52,6 +54,15 @@ describe('Test channel change ownership API validator', function () {
}
})
+ it('Should fail to create a request for a channel of an administrator with a moderator', async function () {
+ await server.changeOwnership.createChannel({
+ channelName: 'root_channel',
+ username: 'moderator',
+ token: moderatorToken,
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
+ })
+ })
+
it('Should fail with a non existing target', async function () {
await server.changeOwnership.createChannel({
channelName: 'user_channel',
@@ -281,6 +292,55 @@ describe('Test channel change ownership API validator', function () {
})
})
+ describe('Accept ownership change request on behalf of the next owner', function () {
+ before(async function () {
+ this.timeout(60000)
+
+ await server.channels.create({ attributes: { name: 'root_channel_3' } })
+ await server.channels.create({ attributes: { name: 'root_channel_4' } })
+ await server.channels.create({ attributes: { name: 'root_channel_5' } })
+
+ await server.users.generateUserAndToken('moderator2', UserRole.MODERATOR)
+ await server.users.create({ username: 'quota_limited_channel_target', videoQuota: 0 })
+
+ await server.changeOwnership.createChannel({ channelName: 'root_channel_3', username: 'user' })
+ await server.changeOwnership.createChannel({ channelName: 'root_channel_4', username: 'quota_limited_channel_target' })
+ await server.changeOwnership.createChannel({ channelName: 'root_channel_5', username: 'moderator2' })
+ })
+
+ it('Should fail to accept, on behalf of another moderator, a pending channel ownership change, with a moderator', async function () {
+ const { data } = await server.changeOwnership.listOfChannel({ channelName: 'root_channel_5' })
+ const ownershipId = data[0].id
+
+ await server.changeOwnership.acceptChannel({
+ ownershipId,
+ token: moderatorToken,
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
+ })
+ })
+
+ it('Should fail to accept, on behalf of a user whose quota is exceeded, a pending channel ownership change, with a moderator', async function () {
+ const { data } = await server.changeOwnership.listOfChannel({ channelName: 'root_channel_4' })
+ const ownershipId = data[0].id
+
+ await server.changeOwnership.acceptChannel({
+ ownershipId,
+ token: moderatorToken,
+ expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413
+ })
+ })
+
+ it('Should succeed to accept, on behalf of a regular user, a pending channel ownership change, with a moderator', async function () {
+ const { data } = await server.changeOwnership.listOfChannel({ channelName: 'root_channel_3' })
+ const ownershipId = data[0].id
+
+ await server.changeOwnership.acceptChannel({ ownershipId, token: moderatorToken })
+
+ const channel = await server.channels.get({ channelName: 'root_channel_3' })
+ expect(channel.ownerAccount.name).to.equal('user')
+ })
+ })
+
describe('Delete ownership change request', function () {
let deleteOwnershipChangeId: number
diff --git a/packages/tests/src/api/check-params/token-session.ts b/packages/tests/src/api/check-params/token-session.ts
index 22c2fb5d16..a5e4af21a2 100644
--- a/packages/tests/src/api/check-params/token-session.ts
+++ b/packages/tests/src/api/check-params/token-session.ts
@@ -1,6 +1,6 @@
/* oxlint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import { HttpStatusCode, User } from '@peertube/peertube-models'
+import { HttpStatusCode, User, UserRole } from '@peertube/peertube-models'
import {
cleanupTests,
createSingleServer,
@@ -14,7 +14,11 @@ describe('Test token session API validators', function () {
let server: PeerTubeServer
let userToken1: string
let userToken2: string
+ let moderatorToken: string
+ let moderatorToken2: string
let user1: User
+ let rootId: number
+ let moderator2Id: number
let path: string
// ---------------------------------------------------------------
@@ -29,8 +33,15 @@ describe('Test token session API validators', function () {
userToken1 = await server.users.generateUserAndToken('user1')
userToken2 = await server.users.generateUserAndToken('user2')
+ moderatorToken = await server.users.generateUserAndToken('moderator1', UserRole.MODERATOR)
+ moderatorToken2 = await server.users.generateUserAndToken('moderator2', UserRole.MODERATOR)
user1 = await server.users.getMyInfo({ token: userToken1 })
+ const root = await server.users.getMyInfo()
+ rootId = root.id
+
+ const moderator2 = await server.users.getMyInfo({ token: moderatorToken2 })
+ moderator2Id = moderator2.id
path = `/api/v1/users/${user1.id}/token-sessions`
})
@@ -68,6 +79,28 @@ describe('Test token session API validators', function () {
it('Should succeed with the correct parameters', async function () {
await makeGetRequest({ url: server.url, path, token: userToken1, expectedStatus: HttpStatusCode.OK_200 })
})
+
+ it('Should fail to list token sessions of an administrator with a moderator', async function () {
+ await makeGetRequest({
+ url: server.url,
+ path: `/api/v1/users/${rootId}/token-sessions`,
+ token: moderatorToken,
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
+ })
+ })
+
+ it('Should succeed to list token sessions of a regular user with a moderator', async function () {
+ await makeGetRequest({ url: server.url, path, token: moderatorToken, expectedStatus: HttpStatusCode.OK_200 })
+ })
+
+ it('Should fail to list token sessions of another moderator with a moderator', async function () {
+ await makeGetRequest({
+ url: server.url,
+ path: `/api/v1/users/${moderator2Id}/token-sessions`,
+ token: moderatorToken,
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
+ })
+ })
})
describe('When revoking a token session', function () {
@@ -108,6 +141,30 @@ describe('Test token session API validators', function () {
it('Should succeed with the correct parameters', async function () {
await makeGetRequest({ url: server.url, path, token: userToken1, expectedStatus: HttpStatusCode.OK_200 })
})
+
+ it('Should fail to revoke a token session of an administrator with a moderator', async function () {
+ const { data } = await server.login.listSessions({ userId: rootId })
+ const rootSessionId = data[0].id
+
+ await server.login.revokeSession({
+ userId: rootId,
+ sessionId: rootSessionId,
+ token: moderatorToken,
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
+ })
+ })
+
+ it('Should fail to revoke a token session of another moderator with a moderator', async function () {
+ const { data } = await server.login.listSessions({ userId: moderator2Id, token: moderatorToken2 })
+ const moderator2SessionId = data[0].id
+
+ await server.login.revokeSession({
+ userId: moderator2Id,
+ sessionId: moderator2SessionId,
+ token: moderatorToken,
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
+ })
+ })
})
after(async function () {
diff --git a/packages/tests/src/api/check-params/two-factor.ts b/packages/tests/src/api/check-params/two-factor.ts
index e6042228d6..6a977bd0bb 100644
--- a/packages/tests/src/api/check-params/two-factor.ts
+++ b/packages/tests/src/api/check-params/two-factor.ts
@@ -1,6 +1,6 @@
/* oxlint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import { HttpStatusCode } from '@peertube/peertube-models'
+import { HttpStatusCode, UserRole } from '@peertube/peertube-models'
import {
cleanupTests,
createSingleServer,
@@ -23,6 +23,11 @@ describe('Test two factor API validators', function () {
let userRequestToken: string
let userOTPToken: string
+ let moderatorToken: string
+ let moderator2Id: number
+
+ let user2Id: number
+
// ---------------------------------------------------------------
before(async function () {
@@ -45,6 +50,21 @@ describe('Test two factor API validators', function () {
rootId = id
rootPassword = server.store.user.password
}
+
+ {
+ const result = await server.users.generate('moderator1', UserRole.MODERATOR)
+ moderatorToken = result.token
+ }
+
+ {
+ const result = await server.users.generate('moderator2', UserRole.MODERATOR)
+ moderator2Id = result.userId
+ }
+
+ {
+ const result = await server.users.generate('user2')
+ user2Id = result.userId
+ }
})
describe('When requesting two factor', function () {
@@ -285,6 +305,34 @@ describe('Test two factor API validators', function () {
})
})
+ describe('When a moderator manages two factor of other users', function () {
+ it('Should fail to request two factor of an administrator with a moderator', async function () {
+ await server.twoFactor.request({ userId: rootId, token: moderatorToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ })
+
+ it('Should fail to request two factor of another moderator with a moderator', async function () {
+ await server.twoFactor.request({ userId: moderator2Id, token: moderatorToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ })
+
+ it('Should fail to disable two factor of an administrator with a moderator', async function () {
+ await server.twoFactor.disable({ userId: rootId, token: moderatorToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ })
+
+ it('Should succeed to request, confirm and disable two factor of a regular user with a moderator', async function () {
+ const { otpRequest } = await server.twoFactor.request({ userId: user2Id, token: moderatorToken })
+ const otpToken = TwoFactorCommand.buildOTP({ secret: otpRequest.secret }).generate()
+
+ await server.twoFactor.confirmRequest({
+ userId: user2Id,
+ token: moderatorToken,
+ requestToken: otpRequest.requestToken,
+ otpToken
+ })
+
+ await server.twoFactor.disable({ userId: user2Id, token: moderatorToken })
+ })
+ })
+
after(async function () {
await cleanupTests([ server ])
})
diff --git a/packages/tests/src/api/check-params/video-change-ownership.ts b/packages/tests/src/api/check-params/video-change-ownership.ts
index 24f47b9feb..1ed1928f9f 100644
--- a/packages/tests/src/api/check-params/video-change-ownership.ts
+++ b/packages/tests/src/api/check-params/video-change-ownership.ts
@@ -1,6 +1,6 @@
/* oxlint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import { ChangeOwnershipState, HttpStatusCode, VideoCreateResult } from '@peertube/peertube-models'
+import { ChangeOwnershipState, HttpStatusCode, UserRole, VideoCreateResult } from '@peertube/peertube-models'
import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@peertube/peertube-server-commands'
import { expect } from 'chai'
@@ -10,6 +10,7 @@ describe('Test video change ownership API validator', function () {
let anotherUserToken: string
let rootEditorToken: string
let userEditorToken: string
+ let moderatorToken: string
let ownershipChangeId: number
let userVideo: VideoCreateResult
@@ -29,6 +30,7 @@ describe('Test video change ownership API validator', function () {
anotherUserToken = await server.users.generateUserAndToken('another_user')
rootEditorToken = await server.channelCollaborators.createEditor('root_editor', 'root_channel')
userEditorToken = await server.channelCollaborators.createEditor('user_editor', 'user_channel')
+ moderatorToken = await server.users.generateUserAndToken('moderator', UserRole.MODERATOR)
rootVideo = await server.videos.quickUpload({ name: 'root video' })
rootVideo2 = await server.videos.quickUpload({ name: 'root video 2' })
@@ -258,6 +260,18 @@ describe('Test video change ownership API validator', function () {
})
})
+ it('Should fail with a target channel that does not belong to the next owner, even if accepted by a moderator', async function () {
+ const me = await server.users.getMyInfo({ token: moderatorToken })
+ const moderatorChannelId = me.videoChannels[0].id
+
+ await server.changeOwnership.acceptVideo({
+ ownershipId: ownershipChangeId,
+ token: moderatorToken,
+ channelId: moderatorChannelId,
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
+ })
+ })
+
it('Should succeed with valid params', async function () {
await server.changeOwnership.acceptVideo({
ownershipId: ownershipChangeId,
@@ -276,6 +290,77 @@ describe('Test video change ownership API validator', function () {
})
})
+ describe('Accept ownership change request on behalf of the next owner', function () {
+ let moderator2Token: string
+ let quotaLimitedToken: string
+
+ let videoForRegularUser: VideoCreateResult
+ let videoForQuotaLimitedUser: VideoCreateResult
+ let videoForModerator2: VideoCreateResult
+
+ before(async function () {
+ this.timeout(120000)
+
+ moderator2Token = await server.users.generateUserAndToken('moderator2', UserRole.MODERATOR)
+
+ await server.users.create({ username: 'quota_limited_video_target', videoQuota: 0 })
+ quotaLimitedToken = await server.login.getAccessToken({ username: 'quota_limited_video_target', password: 'password' })
+
+ videoForRegularUser = await server.videos.quickUpload({ name: 'root video for moderator accept' })
+ await server.changeOwnership.createVideo({ videoId: videoForRegularUser.id, username: 'user' })
+
+ videoForQuotaLimitedUser = await server.videos.quickUpload({ name: 'root video for quota limited target' })
+ await server.changeOwnership.createVideo({ videoId: videoForQuotaLimitedUser.id, username: 'quota_limited_video_target' })
+
+ videoForModerator2 = await server.videos.quickUpload({ name: 'root video for moderator2 target' })
+ await server.changeOwnership.createVideo({ videoId: videoForModerator2.id, username: 'moderator2' })
+ })
+
+ it('Should fail to accept, on behalf of another moderator, a pending video ownership change, with a moderator', async function () {
+ const { data } = await server.changeOwnership.listOfVideo({ videoId: videoForModerator2.id })
+ const ownershipId = data[0].id
+
+ const me = await server.users.getMyInfo({ token: moderator2Token })
+
+ await server.changeOwnership.acceptVideo({
+ ownershipId,
+ token: moderatorToken,
+ channelId: me.videoChannels[0].id,
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
+ })
+ })
+
+ it('Should fail to accept, on behalf of a user whose quota is exceeded, a pending video ownership change, with a moderator', async function () {
+ const { data } = await server.changeOwnership.listOfVideo({ videoId: videoForQuotaLimitedUser.id })
+ const ownershipId = data[0].id
+
+ const me = await server.users.getMyInfo({ token: quotaLimitedToken })
+
+ await server.changeOwnership.acceptVideo({
+ ownershipId,
+ token: moderatorToken,
+ channelId: me.videoChannels[0].id,
+ expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413
+ })
+ })
+
+ it('Should succeed to accept, on behalf of a regular user, a pending video ownership change, with a moderator', async function () {
+ const { data } = await server.changeOwnership.listOfVideo({ videoId: videoForRegularUser.id })
+ const ownershipId = data[0].id
+
+ const me = await server.users.getMyInfo({ token: userToken })
+
+ await server.changeOwnership.acceptVideo({
+ ownershipId,
+ token: moderatorToken,
+ channelId: me.videoChannels[0].id
+ })
+
+ const video = await server.videos.get({ id: videoForRegularUser.id })
+ expect(video.account.name).to.equal('user')
+ })
+ })
+
describe('Delete ownership change request', function () {
let deleteOwnershipChangeId: number
let videoId: string
diff --git a/packages/tests/src/api/check-params/video-playlists.ts b/packages/tests/src/api/check-params/video-playlists.ts
index 303717405f..8080542ef7 100644
--- a/packages/tests/src/api/check-params/video-playlists.ts
+++ b/packages/tests/src/api/check-params/video-playlists.ts
@@ -2,6 +2,7 @@
import {
HttpStatusCode,
+ UserRole,
VideoChannelCreateResult,
VideoPlaylistCreate,
VideoPlaylistCreateResult,
@@ -27,6 +28,7 @@ describe('Test video playlists API validator', function () {
let server: PeerTubeServer
let userAccessToken: string
let editorToken: string
+ let moderatorToken: string
let playlist: VideoPlaylistCreateResult
let userPlaylist: VideoPlaylistCreateResult
@@ -34,6 +36,8 @@ describe('Test video playlists API validator', function () {
let privatePlaylistUUID: string
let privatePlaylistElementId: number
+ let privateUserPlaylistUUID: string
+
let anotherChannelPlaylistUUID: string
let anotherChannelPlaylistElementId: number
@@ -63,6 +67,7 @@ describe('Test video playlists API validator', function () {
const user = await server.users.getMyInfo({ token: userAccessToken })
editorToken = await server.channelCollaborators.createEditor('editor', 'root_channel')
+ moderatorToken = await server.users.generateUserAndToken('moderator', UserRole.MODERATOR)
videoId = (await server.videos.quickUpload({ name: 'video 1' })).id
@@ -137,6 +142,17 @@ describe('Test video playlists API validator', function () {
}
})
}
+
+ {
+ const created = await command.create({
+ token: userAccessToken,
+ attributes: {
+ displayName: 'private user playlist',
+ privacy: VideoPlaylistPrivacy.PRIVATE
+ }
+ })
+ privateUserPlaylistUUID = created.uuid
+ }
})
describe('When listing playlists', function () {
@@ -258,6 +274,14 @@ describe('Test video playlists API validator', function () {
}
}
})
+
+ it('Should succeed to get the private playlist of an administrator with a moderator', async function () {
+ await command.get({ playlistId: privatePlaylistUUID, token: moderatorToken, expectedStatus: HttpStatusCode.OK_200 })
+ })
+
+ it('Should succeed to get the private playlist of a regular user with a moderator', async function () {
+ await command.get({ playlistId: privateUserPlaylistUUID, token: moderatorToken, expectedStatus: HttpStatusCode.OK_200 })
+ })
})
describe('When creating/updating a video playlist', function () {
diff --git a/packages/tests/src/api/check-params/watched-words.ts b/packages/tests/src/api/check-params/watched-words.ts
index d53bd55a6a..8f8130ff75 100644
--- a/packages/tests/src/api/check-params/watched-words.ts
+++ b/packages/tests/src/api/check-params/watched-words.ts
@@ -34,6 +34,7 @@ describe('Test watched words API validators', function () {
userToken = await server.users.generateUserAndToken('user1')
userToken2 = await server.users.generateUserAndToken('user2')
moderatorToken = await server.users.generateUserAndToken('moderator', UserRole.MODERATOR)
+ await server.users.generateUserAndToken('moderator2', UserRole.MODERATOR)
command = server.watchedWordsLists
@@ -244,6 +245,47 @@ describe('Test watched words API validators', function () {
await command.deleteList({ ...baseParams(), accountName: 'unknown', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
})
})
+
+ describe('When a moderator manages watched words of other accounts', function () {
+ it('Should succeed to manage watched words of an administrator with a moderator', async function () {
+ await command.listWordsLists({ accountName: 'root', token: moderatorToken })
+
+ const { watchedWordsList } = await command.createList({
+ accountName: 'root',
+ token: moderatorToken,
+ listName: 'moderator-list-on-admin',
+ words: [ 'word1' ]
+ })
+
+ await command.deleteList({ accountName: 'root', token: moderatorToken, listId: watchedWordsList.id })
+ })
+
+ it('Should succeed to manage watched words of another moderator with a moderator', async function () {
+ await command.listWordsLists({ accountName: 'moderator2', token: moderatorToken })
+
+ const { watchedWordsList } = await command.createList({
+ accountName: 'moderator2',
+ token: moderatorToken,
+ listName: 'moderator-list-on-moderator',
+ words: [ 'word1' ]
+ })
+
+ await command.deleteList({ accountName: 'moderator2', token: moderatorToken, listId: watchedWordsList.id })
+ })
+
+ it('Should succeed to manage watched words of a regular user with a moderator', async function () {
+ await command.listWordsLists({ accountName: 'user1', token: moderatorToken })
+
+ const { watchedWordsList } = await command.createList({
+ accountName: 'user1',
+ token: moderatorToken,
+ listName: 'moderator-list',
+ words: [ 'word1' ]
+ })
+
+ await command.deleteList({ accountName: 'user1', token: moderatorToken, listId: watchedWordsList.id })
+ })
+ })
})
after(async function () {
diff --git a/packages/tests/src/api/search/search-activitypub-videos.ts b/packages/tests/src/api/search/search-activitypub-videos.ts
index 7563616c31..b9748877d8 100644
--- a/packages/tests/src/api/search/search-activitypub-videos.ts
+++ b/packages/tests/src/api/search/search-activitypub-videos.ts
@@ -207,6 +207,45 @@ describe('Test ActivityPub videos search', function () {
expect(body.data[0].uuid).to.equal(uuid)
})
+ it('Should require authentication or a password to find a password protected video via URI search', async function () {
+ const userToken = await servers[0].users.generateUserAndToken('user_password_video_search')
+ const videoPassword = 'my super password'
+
+ const { uuid } = await servers[0].videos.upload({
+ attributes: { name: 'password protected video', privacy: VideoPrivacy.PASSWORD_PROTECTED, videoPasswords: [ videoPassword ] }
+ })
+ const search = servers[0].url + '/videos/watch/' + uuid
+
+ // Force path where we load the video from local database
+ await servers[0].config.updateExistingConfig({ newConfig: { search: { remoteUri: { users: false, anonymous: false } } } })
+
+ // No password, no auth
+ await command.searchVideos({ search, token: undefined, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ // No password, authenticated but not allowed to bypass it
+ await command.searchVideos({ search, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ // Wrong password
+ await command.searchVideos({
+ search,
+ token: undefined,
+ videoPassword: 'wrong password',
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
+ })
+
+ // Correct password, no auth needed
+ {
+ const body = await command.searchVideos({ search, token: undefined, videoPassword })
+ expect(body.total).to.equal(1)
+ expect(body.data[0].uuid).to.equal(uuid)
+ }
+
+ // Owner can find it without a password
+ {
+ const body = await command.searchVideos({ search, token: servers[0].accessToken })
+ expect(body.total).to.equal(1)
+ expect(body.data[0].uuid).to.equal(uuid)
+ }
+ })
+
after(async function () {
await cleanupTests(servers)
})
diff --git a/server/core/controllers/api/search/search-video-playlists.ts b/server/core/controllers/api/search/search-video-playlists.ts
index 9de3b62bf2..df53c32293 100644
--- a/server/core/controllers/api/search/search-video-playlists.ts
+++ b/server/core/controllers/api/search/search-video-playlists.ts
@@ -17,12 +17,9 @@ import { MVideoPlaylistFullSummary } from '@server/types/models/index.js'
import {
HttpStatusCode,
ResultList,
- UserRight,
VideoPlaylist,
- VideoPlaylistPrivacy,
VideoPlaylistsSearchQueryAfterSanitize
} from '@peertube/peertube-models'
-import { authenticateOrFail } from '../../../middlewares/auth.js'
import {
asyncMiddleware,
openapiOperationDoc,
@@ -33,7 +30,7 @@ import {
videoPlaylistsListSearchValidator,
videoPlaylistsSearchSortValidator
} from '../../../middlewares/index.js'
-import { checkCanManagePlaylist } from '../../../middlewares/validators/videos/video-playlists.js'
+import { checkCanSeePlaylist } from '../../../middlewares/validators/videos/video-playlists.js'
import { searchLocalUrl } from './shared/index.js'
const logger = createLogger()
@@ -129,21 +126,7 @@ async function searchVideoPlaylistsURI (search: string, req: express.Request, re
}
// The resolved playlist may still be private
- if (videoPlaylist?.privacy === VideoPlaylistPrivacy.PRIVATE) {
- if (!await authenticateOrFail({ req, res })) return
-
- if (
- !await checkCanManagePlaylist({
- user: res.locals.oauth.token.User,
- videoPlaylist,
- right: UserRight.UPDATE_ANY_VIDEO_PLAYLIST,
- req,
- res
- })
- ) {
- return
- }
- }
+ if (videoPlaylist && !await checkCanSeePlaylist({ req, res, videoPlaylist })) return
return res.json({
total: videoPlaylist ? 1 : 0,
diff --git a/server/core/controllers/api/video-channels/ownership.ts b/server/core/controllers/api/video-channels/ownership.ts
index 6ae4486c97..9e8c2e7a84 100644
--- a/server/core/controllers/api/video-channels/ownership.ts
+++ b/server/core/controllers/api/video-channels/ownership.ts
@@ -87,7 +87,8 @@ export {
async function createChangeOwnershipRequest (req: express.Request, res: express.Response) {
const channel = res.locals.videoChannel
- const initiatorAccountId = res.locals.oauth.token.User.Account.id
+ // The initiator is the current owner of the channel, not necessarily the user who made the request (for example a moderator)
+ const initiatorAccountId = channel.accountId
const nextOwner = res.locals.changeOwnershipNextOwner
const ownershipChange = await sequelizeTypescript.transaction(async t => {
diff --git a/server/core/controllers/api/videos/ownership.ts b/server/core/controllers/api/videos/ownership.ts
index 3d540d97b5..c83352a0c4 100644
--- a/server/core/controllers/api/videos/ownership.ts
+++ b/server/core/controllers/api/videos/ownership.ts
@@ -86,7 +86,8 @@ export {
async function createChangeOwnershipRequest (req: express.Request, res: express.Response) {
const video = res.locals.videoWithRights
- const initiatorAccountId = res.locals.oauth.token.User.Account.id
+ // The initiator is the current owner of the video, not necessarily the user who made the request (for example a moderator)
+ const initiatorAccountId = video.VideoChannel.accountId
const nextOwner = res.locals.changeOwnershipNextOwner
const ownershipChange = await sequelizeTypescript.transaction(async t => {
diff --git a/server/core/middlewares/validators/shared/users.ts b/server/core/middlewares/validators/shared/users.ts
index cec2584d69..618fe384bf 100644
--- a/server/core/middlewares/validators/shared/users.ts
+++ b/server/core/middlewares/validators/shared/users.ts
@@ -1,9 +1,9 @@
import { forceNumber } from '@peertube/peertube-core-utils'
-import { HttpStatusCode, UserRightType } from '@peertube/peertube-models'
+import { HttpStatusCode, UserRole, UserRightType } from '@peertube/peertube-models'
import { loadReservedActorName } from '@server/lib/local-actor.js'
import { getByEmailPermissive } from '@server/lib/user.js'
import { UserModel } from '@server/models/user/user.js'
-import { MAccountId, MUserAccountId, MUserDefault } from '@server/types/models/index.js'
+import { MAccountId, MUser, MUserAccountId, MUserDefault } from '@server/types/models/index.js'
import express from 'express'
export function checkUserIdExist (idArg: number | string, res: express.Response, withStats = false) {
@@ -128,6 +128,37 @@ export function checkCanManageAccount (options: {
return false
}
+// Moderators must not manage administrator or other moderator accounts, only admins can manage everyone
+export function canModerate (options: {
+ authUser: MUser
+ onUser: MUser
+}) {
+ const { authUser, onUser } = options
+
+ if (authUser.role === UserRole.ADMINISTRATOR) return true
+ if (authUser.role === UserRole.MODERATOR && onUser.role === UserRole.USER) return true
+
+ return false
+}
+
+export function checkCanModerate (options: {
+ authUser: MUser
+ onUser: MUser
+ req: express.Request
+ res: express.Response
+}) {
+ const { authUser, onUser, req, res } = options
+
+ if (canModerate({ authUser, onUser })) return true
+
+ res.fail({
+ status: HttpStatusCode.FORBIDDEN_403,
+ message: req.t('Moderators cannot manage administrators or other moderators')
+ })
+
+ return false
+}
+
export async function doesUserFeedTokenCorrespond (options: {
id: number
token: string
diff --git a/server/core/middlewares/validators/token.ts b/server/core/middlewares/validators/token.ts
index c03bbfe206..6033c41ab4 100644
--- a/server/core/middlewares/validators/token.ts
+++ b/server/core/middlewares/validators/token.ts
@@ -3,7 +3,7 @@ import { isIdValid } from '@server/helpers/custom-validators/misc.js'
import { OAuthTokenModel } from '@server/models/oauth/oauth-token.js'
import express from 'express'
import { param } from 'express-validator'
-import { checkCanManageAccount, checkUserIdExist } from './shared/users.js'
+import { checkCanManageAccount, checkCanModerate, checkUserIdExist } from './shared/users.js'
import { areValidationErrors } from './shared/utils.js'
export const manageTokenSessionsValidator = [
@@ -19,6 +19,8 @@ export const manageTokenSessionsValidator = [
if (!checkCanManageAccount({ account: targetUser.Account, user: authUser, req, res, specialRight: UserRight.MANAGE_USERS })) return
+ if (targetUser.id !== authUser.id && !checkCanModerate({ authUser, onUser: targetUser, req, res })) return
+
return next()
}
]
diff --git a/server/core/middlewares/validators/two-factor.ts b/server/core/middlewares/validators/two-factor.ts
index 950f72528e..56e6a36659 100644
--- a/server/core/middlewares/validators/two-factor.ts
+++ b/server/core/middlewares/validators/two-factor.ts
@@ -2,7 +2,7 @@ import express from 'express'
import { body, param } from 'express-validator'
import { HttpStatusCode, UserRight } from '@peertube/peertube-models'
import { exists, isIdValid } from '../../helpers/custom-validators/misc.js'
-import { areValidationErrors, checkUserIdExist } from './shared/index.js'
+import { areValidationErrors, checkCanModerate, checkUserIdExist } from './shared/index.js'
const requestOrConfirmTwoFactorValidator = [
param('id').custom(isIdValid),
@@ -10,7 +10,7 @@ const requestOrConfirmTwoFactorValidator = [
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
if (areValidationErrors(req, res)) return
- if (!await checkCanEnableOrDisableTwoFactor(req.params.id, res)) return
+ if (!await checkCanEnableOrDisableTwoFactor(req.params.id, req, res)) return
if (res.locals.user.otpSecret) {
return res.fail({
@@ -40,7 +40,7 @@ const disableTwoFactorValidator = [
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
if (areValidationErrors(req, res)) return
- if (!await checkCanEnableOrDisableTwoFactor(req.params.id, res)) return
+ if (!await checkCanEnableOrDisableTwoFactor(req.params.id, req, res)) return
if (!res.locals.user.otpSecret) {
return res.fail({
@@ -63,12 +63,16 @@ export {
// ---------------------------------------------------------------------------
-async function checkCanEnableOrDisableTwoFactor (userId: number | string, res: express.Response) {
+async function checkCanEnableOrDisableTwoFactor (userId: number | string, req: express.Request, res: express.Response) {
const authUser = res.locals.oauth.token.user
if (!await checkUserIdExist(userId, res)) return
- if (res.locals.user.id !== authUser.id && authUser.hasRight(UserRight.MANAGE_USERS) !== true) {
+ const targetUser = res.locals.user
+
+ if (targetUser.id === authUser.id) return true
+
+ if (authUser.hasRight(UserRight.MANAGE_USERS) !== true) {
res.fail({
status: HttpStatusCode.FORBIDDEN_403,
message: `User ${authUser.username} does not have right to change two factor setting of this user.`
@@ -77,5 +81,7 @@ async function checkCanEnableOrDisableTwoFactor (userId: number | string, res: e
return false
}
+ if (!checkCanModerate({ authUser, onUser: targetUser, req, res })) return false
+
return true
}
diff --git a/server/core/middlewares/validators/users/users.ts b/server/core/middlewares/validators/users/users.ts
index f195037a06..5f25d65cc5 100644
--- a/server/core/middlewares/validators/users/users.ts
+++ b/server/core/middlewares/validators/users/users.ts
@@ -4,7 +4,6 @@ import { isStringArray } from '@server/helpers/custom-validators/search.js'
import { isNSFWFlagsValid } from '@server/helpers/custom-validators/videos.js'
import { loadReservedActorName } from '@server/lib/local-actor.js'
import { Hooks } from '@server/lib/plugins/hooks.js'
-import { MUser } from '@server/types/models/user/user.js'
import express from 'express'
import { body, param, query } from 'express-validator'
import { exists, isIdValid, toArray, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc.js'
@@ -37,6 +36,7 @@ import { isThemeRegistered } from '../../../lib/plugins/theme-utils.js'
import { Redis } from '../../../lib/redis.js'
import {
areValidationErrors,
+ checkCanModerate,
checkEmailDoesNotAlreadyExist,
checkUserEmailExistPermissive,
checkUserIdExist,
@@ -131,7 +131,7 @@ export const usersRemoveValidator = [
return res.fail({ message: 'Cannot remove the root user' })
}
- if (!checkCanModerate(user, res)) return
+ if (!checkCanModerate({ authUser: res.locals.oauth.token.User, onUser: user, req, res })) return
return next()
}
@@ -153,7 +153,7 @@ export const usersBlockToggleValidator = [
return res.fail({ message: 'Cannot block the root user' })
}
- if (!checkCanModerate(user, res)) return
+ if (!checkCanModerate({ authUser: res.locals.oauth.token.User, onUser: user, req, res })) return
return next()
}
@@ -208,7 +208,7 @@ export const usersUpdateValidator = [
return res.fail({ message: 'Cannot change root role.' })
}
- if (!checkCanModerate(user, res)) return
+ if (!checkCanModerate({ authUser: res.locals.oauth.token.User, onUser: user, req, res })) return
if (req.body.role !== undefined && !checkCanSetRole(req.body.role, res)) return
if (
@@ -505,20 +505,6 @@ export const usersNewFeatureInfoReadValidator = [
// Private
// ---------------------------------------------------------------------------
-function checkCanModerate (onUser: MUser, res: express.Response) {
- const authUser = res.locals.oauth.token.User
-
- if (authUser.role === UserRole.ADMINISTRATOR) return true
- if (authUser.role === UserRole.MODERATOR && onUser.role === UserRole.USER) return true
-
- res.fail({
- status: HttpStatusCode.FORBIDDEN_403,
- message: 'Users can only be managed by moderators or admins.'
- })
-
- return false
-}
-
function checkCanSetRole (role: UserRoleType, res: express.Response) {
const authUser = res.locals.oauth.token.User
diff --git a/server/core/middlewares/validators/videos/change-ownership.ts b/server/core/middlewares/validators/videos/change-ownership.ts
index 1fc79681b8..3205b543ca 100644
--- a/server/core/middlewares/validators/videos/change-ownership.ts
+++ b/server/core/middlewares/validators/videos/change-ownership.ts
@@ -14,13 +14,16 @@ import { AccountModel } from '@server/models/account/account.js'
import { ChangeOwnershipModel } from '@server/models/video/change-ownership.js'
import { VideoChannelModel } from '@server/models/video/video-channel.js'
import { VideoModel } from '@server/models/video/video.js'
+import { UserModel } from '@server/models/user/user.js'
+import { MUserAccountId } from '@server/types/models/index.js'
import express from 'express'
-import { param, query } from 'express-validator'
+import { body, param, query } from 'express-validator'
import {
areValidationErrors,
checkCanManageAccount,
checkCanManageChannel,
checkCanManageVideo,
+ checkCanModerate,
checkUserQuota,
doesChangeOwnershipExist,
doesChannelHandleExist,
@@ -64,6 +67,14 @@ export const acceptOrRejectChangeOwnershipValidatorFactory = (type: 'video' | 'c
return
}
+ // Moderators must not manage administrator or other moderator accounts
+ if (videoChangeOwnership.NextOwner.id !== user.Account.id) {
+ const nextOwnerUser = await loadNextOwnerUserOrFail({ nextOwnerAccountId: videoChangeOwnership.NextOwner.id, req, res })
+ if (!nextOwnerUser) return
+
+ if (!checkCanModerate({ authUser: user, onUser: nextOwnerUser, req, res })) return
+ }
+
const changeOwnership = res.locals.changeOwnership
if (changeOwnership.state !== ChangeOwnershipState.PENDING) {
@@ -128,12 +139,25 @@ export const changeVideoOwnershipValidator = [
]
export const acceptVideoChangeOwnershipValidator = [
+ body('channelId').custom(isIdValid),
+
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
+ if (areValidationErrors(req, res)) return
+
const body = req.body as ChangeVideoOwnershipAccept
- if (!await doesChannelIdExist({ id: body.channelId, req, res, checkCanManage: true, checkIsLocal: true, checkIsOwner: true })) return
+ if (!await doesChannelIdExist({ id: body.channelId, req, res, checkCanManage: false, checkIsLocal: true, checkIsOwner: false })) return
const videoChangeOwnership = res.locals.changeOwnership
+ // The request can be accepted on behalf of the next owner (for example by a moderator)
+ if (res.locals.videoChannel.Account.id !== videoChangeOwnership.NextOwner.id) {
+ res.fail({
+ status: HttpStatusCode.FORBIDDEN_403,
+ message: req.t('This channel does not belong to the next owner of this video')
+ })
+ return
+ }
+
const video = await VideoModel.loadWithFiles(videoChangeOwnership.Video.id)
if (video.isLive) {
@@ -146,9 +170,11 @@ export const acceptVideoChangeOwnershipValidator = [
return
}
} else {
- const channelUser = res.locals.oauth.token.User
+ // Quota must be checked against the next owner, not the user accepting on their behalf (for example a moderator)
+ const nextOwnerUser = await loadNextOwnerUserOrFail({ nextOwnerAccountId: videoChangeOwnership.NextOwner.id, req, res })
+ if (!nextOwnerUser) return
- if (!await checkUserQuota({ channelUser, uploadSize: video.getMaxQualityBytes(), req, res })) return
+ if (!await checkUserQuota({ channelUser: nextOwnerUser, uploadSize: video.getMaxQualityBytes(), req, res })) return
}
return next()
@@ -234,9 +260,20 @@ export const changeChannelOwnershipValidator = [
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
if (areValidationErrors(req, res)) return
if (
- !await doesChannelHandleExist({ handle: req.params.handle, checkCanManage: true, checkIsLocal: true, checkIsOwner: true, req, res })
+ !await doesChannelHandleExist({
+ handle: req.params.handle,
+ checkCanManage: true,
+ checkIsLocal: true,
+ checkIsOwner: true,
+ specialRight: UserRight.CHANGE_CHANNEL_OWNERSHIP,
+ req,
+ res
+ })
) return
+ // Moderators must not manage the ownership of an administrator or another moderator's channel
+ if (!await checkCanModerateChannelOwner({ authUser: res.locals.oauth.token.User, channel: res.locals.videoChannel, req, res })) return
+
if (!await checkNextOwner({ username: req.body.username, req, res })) return
const nextOwner = res.locals.changeOwnershipNextOwner
@@ -271,7 +308,15 @@ export const listChannelOwnershipChangesValidator = [
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
if (areValidationErrors(req, res)) return
if (
- !await doesChannelHandleExist({ handle: req.params.handle, checkCanManage: true, checkIsLocal: true, checkIsOwner: false, req, res })
+ !await doesChannelHandleExist({
+ handle: req.params.handle,
+ checkCanManage: true,
+ checkIsLocal: true,
+ checkIsOwner: false,
+ req,
+ res,
+ specialRight: UserRight.CHANGE_CHANNEL_OWNERSHIP
+ })
) return
return next()
@@ -292,8 +337,12 @@ export const acceptChannelChangeOwnershipValidator = [
return
}
+ // Quota must be checked against the next owner, not the user accepting on their behalf (for example a moderator)
+ const nextOwnerUser = await loadNextOwnerUserOrFail({ nextOwnerAccountId: videoChangeOwnership.NextOwner.id, req, res })
+ if (!nextOwnerUser) return
+
const channelQuota = await VideoChannelModel.getChannelQuota(videoChangeOwnership.VideoChannel.id)
- if (!await checkUserQuota({ channelUser: getAuthUser(res), uploadSize: channelQuota, req, res })) return
+ if (!await checkUserQuota({ channelUser: nextOwnerUser, uploadSize: channelQuota, req, res })) return
return next()
}
@@ -330,10 +379,14 @@ export const deleteChangeChannelOwnershipValidator = [
req,
res,
checkCanManage: true,
- checkIsOwner: true
+ checkIsOwner: true,
+ specialRight: UserRight.CHANGE_CHANNEL_OWNERSHIP
})
) return false
+ // Moderators must not manage the ownership of an administrator or another moderator's channel
+ if (!await checkCanModerateChannelOwner({ authUser: getAuthUser(res), channel, req, res })) return false
+
return next()
}
]
@@ -350,7 +403,8 @@ async function checkNextOwner (options: {
const { username, req, res } = options
const nextOwner = await AccountModel.loadLocalByName(username)
- if (!nextOwner) {
+ // The application/instance account has no user and cannot own a video or a channel
+ if (!nextOwner?.userId) {
res.fail({
message: req.t('{username} does not exist on {instanceName}', { username: username, instanceName: CONFIG.INSTANCE.NAME })
})
@@ -362,6 +416,45 @@ async function checkNextOwner (options: {
return true
}
+// Loads the user behind the next owner account, failing cleanly if that account has no corresponding user anymore
+// (should not happen, but the user could have been removed between the request creation and its acceptance)
+async function loadNextOwnerUserOrFail (options: {
+ nextOwnerAccountId: number
+ req: express.Request
+ res: express.Response
+}) {
+ const { nextOwnerAccountId, req, res } = options
+
+ const nextOwnerUser = await UserModel.loadByAccountId(nextOwnerAccountId)
+
+ if (!nextOwnerUser) {
+ res.fail({
+ status: HttpStatusCode.FORBIDDEN_403,
+ message: req.t('The next owner account does not exist anymore')
+ })
+ return undefined
+ }
+
+ return nextOwnerUser
+}
+
+// Moderators must not manage the ownership of an administrator or another moderator's channel, unless it is their own
+async function checkCanModerateChannelOwner (options: {
+ authUser: MUserAccountId
+ channel: { accountId: number }
+ req: express.Request
+ res: express.Response
+}) {
+ const { authUser, channel, req, res } = options
+
+ if (channel.accountId === authUser.Account.id) return true
+
+ const ownerUser = await UserModel.loadByAccountId(channel.accountId)
+ if (!ownerUser) return true
+
+ return checkCanModerate({ authUser, onUser: ownerUser, req, res })
+}
+
function isOwnershipChangeStateValid (value: any): value is ChangeOwnershipStateType {
return exists(value) && CHANGE_OWNERSHIP_STATES[value] !== undefined
}
diff --git a/server/core/middlewares/validators/videos/video-playlists.ts b/server/core/middlewares/validators/videos/video-playlists.ts
index 938b8379ab..c9455ab183 100644
--- a/server/core/middlewares/validators/videos/video-playlists.ts
+++ b/server/core/middlewares/validators/videos/video-playlists.ts
@@ -197,27 +197,34 @@ export const videoPlaylistsGetValidator = (fetchType: VideoPlaylistFetchType) =>
})
}
- if (videoPlaylist.privacy === VideoPlaylistPrivacy.PRIVATE) {
- if (!await authenticateOrFail({ req, res })) return
-
- if (
- !await checkCanManagePlaylist({
- user: res.locals.oauth.token.User,
- videoPlaylist,
- right: UserRight.UPDATE_ANY_VIDEO_PLAYLIST,
- req,
- res
- })
- ) {
- return
- }
- }
+ if (!await checkCanSeePlaylist({ req, res, videoPlaylist })) return
return next()
}
]
}
+// A private playlist can only be seen by users allowed to manage it (owner, moderator/admin)
+export async function checkCanSeePlaylist (options: {
+ req: express.Request
+ res: express.Response
+ videoPlaylist: MVideoPlaylistFullSummary
+}) {
+ const { req, res, videoPlaylist } = options
+
+ if (videoPlaylist.privacy !== VideoPlaylistPrivacy.PRIVATE) return true
+
+ if (!await authenticateOrFail({ req, res })) return false
+
+ return checkCanManagePlaylist({
+ user: res.locals.oauth.token.User,
+ videoPlaylist,
+ right: UserRight.UPDATE_ANY_VIDEO_PLAYLIST,
+ req,
+ res
+ })
+}
+
export const videoPlaylistsSearchValidator = [
query('search')
.optional()
@@ -512,12 +519,12 @@ export async function checkCanManagePlaylist (options: {
videoPlaylist: MVideoPlaylistFullSummary
right: UserRightType
req: express.Request
- res: express.Response | null
+ res: express.Response
}) {
const { user, videoPlaylist, right, res, req } = options
if (videoPlaylist.isLocal() === false) {
- res?.fail({
+ res.fail({
status: HttpStatusCode.FORBIDDEN_403,
message: req.t('Cannot manage video playlist of another server.')
})
@@ -544,7 +551,7 @@ export async function checkCanManagePlaylist (options: {
}
}
- res?.fail({
+ res.fail({
status: HttpStatusCode.FORBIDDEN_403,
message: req.t('Cannot manage video playlist of another user')
})