fix(API): Allow RequestOnBehalf rights if requested from the API (#4919)

This commit is contained in:
phildups7 2023-05-09 05:25:37 -04:00 committed by GitHub
commit bb6deddfae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View file

@ -80,7 +80,8 @@ namespace Ombi.Core.Engine
var userDetails = await GetUser(); var userDetails = await GetUser();
var canRequestOnBehalf = model.RequestOnBehalf.HasValue(); 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); || await UserManager.IsInRoleAsync(userDetails, OmbiRoles.Admin);
if (canRequestOnBehalf && !isAdmin) if (canRequestOnBehalf && !isAdmin)
{ {

View file

@ -161,7 +161,7 @@ namespace Ombi.Core.Engine
var user = await GetUser(); var user = await GetUser();
var canRequestOnBehalf = tv.RequestOnBehalf.HasValue(); 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) if (tv.RequestOnBehalf.HasValue() && !isAdmin)
{ {
return new RequestEngineResult return new RequestEngineResult