From bb6deddfaecb3d6c7c3c6970414444b619bb9106 Mon Sep 17 00:00:00 2001 From: phildups7 <60622768+phildups7@users.noreply.github.com> Date: Tue, 9 May 2023 05:25:37 -0400 Subject: [PATCH] fix(API): Allow RequestOnBehalf rights if requested from the API (#4919) --- src/Ombi.Core/Engine/MovieRequestEngine.cs | 3 ++- src/Ombi.Core/Engine/TvRequestEngine.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Ombi.Core/Engine/MovieRequestEngine.cs b/src/Ombi.Core/Engine/MovieRequestEngine.cs index 7863aed25..4d3cd2cf9 100644 --- a/src/Ombi.Core/Engine/MovieRequestEngine.cs +++ b/src/Ombi.Core/Engine/MovieRequestEngine.cs @@ -80,7 +80,8 @@ namespace Ombi.Core.Engine var userDetails = await GetUser(); var canRequestOnBehalf = model.RequestOnBehalf.HasValue(); - var isAdmin = await UserManager.IsInRoleAsync(userDetails, OmbiRoles.PowerUser) + var isAdmin = Username.Equals("API", StringComparison.CurrentCultureIgnoreCase) + || await UserManager.IsInRoleAsync(userDetails, OmbiRoles.PowerUser) || await UserManager.IsInRoleAsync(userDetails, OmbiRoles.Admin); if (canRequestOnBehalf && !isAdmin) { diff --git a/src/Ombi.Core/Engine/TvRequestEngine.cs b/src/Ombi.Core/Engine/TvRequestEngine.cs index 8ccc6d17e..5ebce9586 100644 --- a/src/Ombi.Core/Engine/TvRequestEngine.cs +++ b/src/Ombi.Core/Engine/TvRequestEngine.cs @@ -161,7 +161,7 @@ namespace Ombi.Core.Engine var user = await GetUser(); var canRequestOnBehalf = tv.RequestOnBehalf.HasValue(); - var isAdmin = await UserManager.IsInRoleAsync(user, OmbiRoles.PowerUser) || await UserManager.IsInRoleAsync(user, OmbiRoles.Admin); + var isAdmin = Username.Equals("API", StringComparison.CurrentCultureIgnoreCase) || await UserManager.IsInRoleAsync(user, OmbiRoles.PowerUser) || await UserManager.IsInRoleAsync(user, OmbiRoles.Admin); if (tv.RequestOnBehalf.HasValue() && !isAdmin) { return new RequestEngineResult