From 8e42dbf8f78caa51ca891bf3d702c6b0ac401f9c Mon Sep 17 00:00:00 2001
From: tidusjar <tidusjar@gmail.com>
Date: Thu, 3 Feb 2022 09:00:05 +0000
Subject: [PATCH] fix(API): Fixed an issue where the API key couldn't delete a
 request #4489

---
 src/Ombi.Core/Engine/Interfaces/BaseEngine.cs | 7 ++++++-
 src/Ombi.sln                                  | 8 ++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/Ombi.Core/Engine/Interfaces/BaseEngine.cs b/src/Ombi.Core/Engine/Interfaces/BaseEngine.cs
index e949ac297..42aff9a61 100644
--- a/src/Ombi.Core/Engine/Interfaces/BaseEngine.cs
+++ b/src/Ombi.Core/Engine/Interfaces/BaseEngine.cs
@@ -45,7 +45,12 @@ namespace Ombi.Core.Engine.Interfaces
 
         protected async Task<bool> IsInRole(string roleName)
         {
-            return await UserManager.IsInRoleAsync(await GetUser(), roleName);
+            if (Username.Equals("API", StringComparison.CurrentCultureIgnoreCase))
+            {
+                return true;
+            }
+            var user = await GetUser();
+            return await UserManager.IsInRoleAsync(user, roleName);
         }
         
         public async Task<IEnumerable<RuleResult>> RunRequestRules(BaseRequest model)
diff --git a/src/Ombi.sln b/src/Ombi.sln
index 5149f020b..841f84dbd 100644
--- a/src/Ombi.sln
+++ b/src/Ombi.sln
@@ -124,6 +124,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi.Api.CloudService", "Om
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi.Api.RottenTomatoes", "Ombi.Api.RottenTomatoes\Ombi.Api.RottenTomatoes.csproj", "{8F19C701-7881-4BC7-8BBA-B068A6B954AD}"
 EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi.I18n", "Ombi.I18n\Ombi.I18n.csproj", "{6A922D57-8622-4C36-8E6E-D5BA9E8DA6C0}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -431,6 +433,12 @@ Global
 		{8F19C701-7881-4BC7-8BBA-B068A6B954AD}.NonUiBuild|Any CPU.Build.0 = NonUiBuild|Any CPU
 		{8F19C701-7881-4BC7-8BBA-B068A6B954AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{8F19C701-7881-4BC7-8BBA-B068A6B954AD}.Release|Any CPU.Build.0 = Release|Any CPU
+		{6A922D57-8622-4C36-8E6E-D5BA9E8DA6C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{6A922D57-8622-4C36-8E6E-D5BA9E8DA6C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{6A922D57-8622-4C36-8E6E-D5BA9E8DA6C0}.NonUiBuild|Any CPU.ActiveCfg = NonUiBuild|Any CPU
+		{6A922D57-8622-4C36-8E6E-D5BA9E8DA6C0}.NonUiBuild|Any CPU.Build.0 = NonUiBuild|Any CPU
+		{6A922D57-8622-4C36-8E6E-D5BA9E8DA6C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{6A922D57-8622-4C36-8E6E-D5BA9E8DA6C0}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE