From 224a6a4103f81ccfb1d580c8734f9b3898940610 Mon Sep 17 00:00:00 2001 From: Patrick Collins Date: Thu, 9 May 2019 03:34:13 -0400 Subject: [PATCH 1/4] fix album-request-permission error message --- src/Ombi.Core/Rule/Rules/Request/CanRequestRule.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Ombi.Core/Rule/Rules/Request/CanRequestRule.cs b/src/Ombi.Core/Rule/Rules/Request/CanRequestRule.cs index 1cdf03955..d3ae80f62 100644 --- a/src/Ombi.Core/Rule/Rules/Request/CanRequestRule.cs +++ b/src/Ombi.Core/Rule/Rules/Request/CanRequestRule.cs @@ -32,15 +32,16 @@ namespace Ombi.Core.Rule.Rules { if (User.IsInRole(OmbiRoles.RequestTv) || User.IsInRole(OmbiRoles.AutoApproveTv)) return Task.FromResult(Success()); + return Task.FromResult(Fail("You do not have permissions to Request a TV Show")); } if (obj.RequestType == RequestType.Album) { if (User.IsInRole(OmbiRoles.RequestMusic) || User.IsInRole(OmbiRoles.AutoApproveMusic)) return Task.FromResult(Success()); + return Task.FromResult(Fail("You do not have permissions to Request an Album")); } - return Task.FromResult(Fail("You do not have permissions to Request a TV Show")); } } -} \ No newline at end of file +} From 6c5e359d6919466d253428ca54133341dceff027 Mon Sep 17 00:00:00 2001 From: Patrick Collins Date: Thu, 9 May 2019 04:23:04 -0400 Subject: [PATCH 2/4] add braces to all if statements --- src/Ombi.Core/Rule/Rules/Request/CanRequestRule.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Ombi.Core/Rule/Rules/Request/CanRequestRule.cs b/src/Ombi.Core/Rule/Rules/Request/CanRequestRule.cs index d3ae80f62..a73fd67c8 100644 --- a/src/Ombi.Core/Rule/Rules/Request/CanRequestRule.cs +++ b/src/Ombi.Core/Rule/Rules/Request/CanRequestRule.cs @@ -19,26 +19,37 @@ namespace Ombi.Core.Rule.Rules public Task Execute(BaseRequest obj) { if (User.IsInRole(OmbiRoles.Admin)) + { return Task.FromResult(Success()); + } if (obj.RequestType == RequestType.Movie) { if (User.IsInRole(OmbiRoles.RequestMovie) || User.IsInRole(OmbiRoles.AutoApproveMovie)) + { return Task.FromResult(Success()); + } + return Task.FromResult(Fail("You do not have permissions to Request a Movie")); } if (obj.RequestType == RequestType.TvShow) { if (User.IsInRole(OmbiRoles.RequestTv) || User.IsInRole(OmbiRoles.AutoApproveTv)) + { return Task.FromResult(Success()); + } + return Task.FromResult(Fail("You do not have permissions to Request a TV Show")); } if (obj.RequestType == RequestType.Album) { if (User.IsInRole(OmbiRoles.RequestMusic) || User.IsInRole(OmbiRoles.AutoApproveMusic)) + { return Task.FromResult(Success()); + } + return Task.FromResult(Fail("You do not have permissions to Request an Album")); } From 3556e055df09c71f6dbec6213311250928394e4a Mon Sep 17 00:00:00 2001 From: Patrick Collins Date: Thu, 9 May 2019 19:45:47 -0400 Subject: [PATCH 3/4] add exception to handle unknown RequestType --- src/Ombi.Core/Rule/Rules/Request/CanRequestRule.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Ombi.Core/Rule/Rules/Request/CanRequestRule.cs b/src/Ombi.Core/Rule/Rules/Request/CanRequestRule.cs index a73fd67c8..87c58b1cd 100644 --- a/src/Ombi.Core/Rule/Rules/Request/CanRequestRule.cs +++ b/src/Ombi.Core/Rule/Rules/Request/CanRequestRule.cs @@ -53,6 +53,7 @@ namespace Ombi.Core.Rule.Rules return Task.FromResult(Fail("You do not have permissions to Request an Album")); } + throw new InvalidDataException("Permission check failed: unknown RequestType"); } } } From 36f7527c46808fe8e03d18799bbf5d3b7fb58d23 Mon Sep 17 00:00:00 2001 From: Patrick Collins Date: Thu, 16 May 2019 23:21:58 -0400 Subject: [PATCH 4/4] import System.IO --- src/Ombi.Core/Rule/Rules/Request/CanRequestRule.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Ombi.Core/Rule/Rules/Request/CanRequestRule.cs b/src/Ombi.Core/Rule/Rules/Request/CanRequestRule.cs index 87c58b1cd..678e5ff6a 100644 --- a/src/Ombi.Core/Rule/Rules/Request/CanRequestRule.cs +++ b/src/Ombi.Core/Rule/Rules/Request/CanRequestRule.cs @@ -1,4 +1,5 @@ using Ombi.Store.Entities; +using System.IO; using System.Security.Principal; using System.Threading.Tasks; using Ombi.Core.Rule.Interfaces;