fix(api): check correct permissions for auto approve when requests are created

pull/1136/head
sct 4 years ago
parent 3384eb1c47
commit 3c1a72b038

@ -211,29 +211,31 @@ requestRoutes.post(
media, media,
requestedBy: requestUser, requestedBy: requestUser,
// If the user is an admin or has the "auto approve" permission, automatically approve the request // If the user is an admin or has the "auto approve" permission, automatically approve the request
status: status: req.user?.hasPermission(
req.user?.hasPermission( [
req.body.is4k req.body.is4k
? Permission.AUTO_APPROVE_4K ? Permission.AUTO_APPROVE_4K
: Permission.AUTO_APPROVE : Permission.AUTO_APPROVE,
) ||
req.user?.hasPermission(
req.body.is4k req.body.is4k
? Permission.AUTO_APPROVE_4K_MOVIE ? Permission.AUTO_APPROVE_4K_MOVIE
: Permission.AUTO_APPROVE_MOVIE : Permission.AUTO_APPROVE_MOVIE,
Permission.MANAGE_REQUESTS,
],
{ type: 'or' }
) )
? MediaRequestStatus.APPROVED ? MediaRequestStatus.APPROVED
: MediaRequestStatus.PENDING, : MediaRequestStatus.PENDING,
modifiedBy: modifiedBy: req.user?.hasPermission(
req.user?.hasPermission( [
req.body.is4k req.body.is4k
? Permission.AUTO_APPROVE_4K ? Permission.AUTO_APPROVE_4K
: Permission.AUTO_APPROVE : Permission.AUTO_APPROVE,
) ||
req.user?.hasPermission(
req.body.is4k req.body.is4k
? Permission.AUTO_APPROVE_4K_MOVIE ? Permission.AUTO_APPROVE_4K_MOVIE
: Permission.AUTO_APPROVE_MOVIE : Permission.AUTO_APPROVE_MOVIE,
Permission.MANAGE_REQUESTS,
],
{ type: 'or' }
) )
? req.user ? req.user
: undefined, : undefined,
@ -286,29 +288,31 @@ requestRoutes.post(
media, media,
requestedBy: requestUser, requestedBy: requestUser,
// If the user is an admin or has the "auto approve" permission, automatically approve the request // If the user is an admin or has the "auto approve" permission, automatically approve the request
status: status: req.user?.hasPermission(
req.user?.hasPermission( [
req.body.is4k req.body.is4k
? Permission.AUTO_APPROVE_4K ? Permission.AUTO_APPROVE_4K
: Permission.AUTO_APPROVE : Permission.AUTO_APPROVE,
) ||
req.user?.hasPermission(
req.body.is4k req.body.is4k
? Permission.AUTO_APPROVE_4K_TV ? Permission.AUTO_APPROVE_4K_TV
: Permission.AUTO_APPROVE_TV : Permission.AUTO_APPROVE_TV,
Permission.MANAGE_REQUESTS,
],
{ type: 'or' }
) )
? MediaRequestStatus.APPROVED ? MediaRequestStatus.APPROVED
: MediaRequestStatus.PENDING, : MediaRequestStatus.PENDING,
modifiedBy: modifiedBy: req.user?.hasPermission(
req.user?.hasPermission( [
req.body.is4k req.body.is4k
? Permission.AUTO_APPROVE_4K ? Permission.AUTO_APPROVE_4K
: Permission.AUTO_APPROVE : Permission.AUTO_APPROVE,
) ||
req.user?.hasPermission(
req.body.is4k req.body.is4k
? Permission.AUTO_APPROVE_4K_TV ? Permission.AUTO_APPROVE_4K_TV
: Permission.AUTO_APPROVE_TV : Permission.AUTO_APPROVE_TV,
Permission.MANAGE_REQUESTS,
],
{ type: 'or' }
) )
? req.user ? req.user
: undefined, : undefined,
@ -321,16 +325,17 @@ requestRoutes.post(
(sn) => (sn) =>
new SeasonRequest({ new SeasonRequest({
seasonNumber: sn, seasonNumber: sn,
status: status: req.user?.hasPermission(
req.user?.hasPermission( [
req.body.is4k req.body.is4k
? Permission.AUTO_APPROVE_4K ? Permission.AUTO_APPROVE_4K
: Permission.AUTO_APPROVE : Permission.AUTO_APPROVE,
) ||
req.user?.hasPermission(
req.body.is4k req.body.is4k
? Permission.AUTO_APPROVE_4K_TV ? Permission.AUTO_APPROVE_4K_TV
: Permission.AUTO_APPROVE_TV : Permission.AUTO_APPROVE_TV,
Permission.MANAGE_REQUESTS,
],
{ type: 'or' }
) )
? MediaRequestStatus.APPROVED ? MediaRequestStatus.APPROVED
: MediaRequestStatus.PENDING, : MediaRequestStatus.PENDING,

Loading…
Cancel
Save