From ea6f33102a394cf5d1cc5e3d37a48687399b24bf Mon Sep 17 00:00:00 2001 From: Drewster727 Date: Mon, 4 Apr 2016 09:16:29 -0500 Subject: [PATCH] #132 auto-approve for admins --- PlexRequests.UI/Modules/SearchModule.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/PlexRequests.UI/Modules/SearchModule.cs b/PlexRequests.UI/Modules/SearchModule.cs index 9200d69c4..061ccd9dd 100644 --- a/PlexRequests.UI/Modules/SearchModule.cs +++ b/PlexRequests.UI/Modules/SearchModule.cs @@ -31,6 +31,7 @@ using System.Linq; using Nancy; using Nancy.Responses.Negotiation; +using Nancy.Security; using NLog; @@ -107,6 +108,13 @@ namespace PlexRequests.UI.Modules private IHeadphonesApi HeadphonesApi { get; } private static Logger Log = LogManager.GetCurrentClassLogger(); + private bool IsAdmin { + get + { + return Context.CurrentUser.IsAuthenticated(); + } + } + private Negotiator RequestLoad() { var settings = PrService.GetSettings(); @@ -260,7 +268,7 @@ namespace PlexRequests.UI.Modules }; Log.Trace(settings.DumpJson()); - if (!settings.RequireMovieApproval || settings.ApprovalWhiteList.Any(x => x.Equals(Username, StringComparison.OrdinalIgnoreCase))) + if (IsAdmin || !settings.RequireMovieApproval || settings.ApprovalWhiteList.Any(x => x.Equals(Username, StringComparison.OrdinalIgnoreCase))) { var cpSettings = CpService.GetSettings(); @@ -414,7 +422,7 @@ namespace PlexRequests.UI.Modules model.SeasonList = seasonsList.ToArray(); - if (!settings.RequireTvShowApproval || settings.ApprovalWhiteList.Any(x => x.Equals(Username, StringComparison.OrdinalIgnoreCase))) + if (IsAdmin || !settings.RequireTvShowApproval || settings.ApprovalWhiteList.Any(x => x.Equals(Username, StringComparison.OrdinalIgnoreCase))) { var sonarrSettings = SonarrService.GetSettings(); var sender = new TvSender(SonarrApi, SickrageApi); @@ -529,7 +537,7 @@ namespace PlexRequests.UI.Modules }; - if (!settings.RequireMusicApproval || + if (IsAdmin || !settings.RequireMusicApproval || settings.ApprovalWhiteList.Any(x => x.Equals(Username, StringComparison.OrdinalIgnoreCase))) { Log.Debug("We don't require approval OR the user is in the whitelist");