mirror of https://github.com/Chocobozzz/PeerTube
fix(server): delete another users channel
Since the channel owner isn't necessary the auth user we need to check the right account whether it's the last video or not.pull/4608/head
parent
952881aaf6
commit
416a7f4f35
|
@ -80,7 +80,7 @@ const videoChannelsRemoveValidator = [
|
||||||
if (!await doesVideoChannelNameWithHostExist(req.params.nameWithHost, res)) return
|
if (!await doesVideoChannelNameWithHostExist(req.params.nameWithHost, res)) return
|
||||||
|
|
||||||
if (!checkUserCanDeleteVideoChannel(res.locals.oauth.token.User, res.locals.videoChannel, res)) return
|
if (!checkUserCanDeleteVideoChannel(res.locals.oauth.token.User, res.locals.videoChannel, res)) return
|
||||||
if (!await checkVideoChannelIsNotTheLastOne(res)) return
|
if (!await checkVideoChannelIsNotTheLastOne(res.locals.videoChannel, res)) return
|
||||||
|
|
||||||
return next()
|
return next()
|
||||||
}
|
}
|
||||||
|
@ -174,8 +174,8 @@ function checkUserCanDeleteVideoChannel (user: MUser, videoChannel: MChannelAcco
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkVideoChannelIsNotTheLastOne (res: express.Response) {
|
async function checkVideoChannelIsNotTheLastOne (videoChannel: MChannelAccountDefault, res: express.Response) {
|
||||||
const count = await VideoChannelModel.countByAccount(res.locals.oauth.token.User.Account.id)
|
const count = await VideoChannelModel.countByAccount(videoChannel.Account.id)
|
||||||
|
|
||||||
if (count <= 1) {
|
if (count <= 1) {
|
||||||
res.fail({
|
res.fail({
|
||||||
|
|
Loading…
Reference in New Issue