mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-21 13:53:19 -07:00
parent
05bdfcd550
commit
55f1309140
41 changed files with 494 additions and 261 deletions
|
@ -66,6 +66,7 @@ using PlexRequests.UI.Helpers;
|
|||
using PlexRequests.UI.Models;
|
||||
using Quartz;
|
||||
using Action = PlexRequests.Helpers.Analytics.Action;
|
||||
using HttpStatusCode = Nancy.HttpStatusCode;
|
||||
|
||||
namespace PlexRequests.UI.Modules
|
||||
{
|
||||
|
@ -154,8 +155,8 @@ namespace PlexRequests.UI.Modules
|
|||
NotifySettings = notifyService;
|
||||
RecentlyAdded = recentlyAdded;
|
||||
|
||||
Security.HasPermissionsResponse(Permissions.Administrator);
|
||||
|
||||
Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);
|
||||
|
||||
Get["/"] = _ => Admin();
|
||||
|
||||
Get["/authentication", true] = async (x, ct) => await Authentication();
|
||||
|
@ -826,13 +827,11 @@ namespace PlexRequests.UI.Modules
|
|||
return Response.AsJson(result
|
||||
? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for Newsletter!" }
|
||||
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Response CreateApiKey()
|
||||
{
|
||||
Security.HasPermissionsResponse(Permissions.Administrator);
|
||||
|
||||
Analytics.TrackEventAsync(Category.Admin, Action.Create, "Created API Key", Username, CookieHelper.GetAnalyticClientId(Cookies));
|
||||
var apiKey = Guid.NewGuid().ToString("N");
|
||||
var settings = PrService.GetSettings();
|
||||
|
@ -978,11 +977,11 @@ namespace PlexRequests.UI.Modules
|
|||
if (!isValid)
|
||||
{
|
||||
return Response.AsJson(new JsonResponseModel
|
||||
{
|
||||
Result = false,
|
||||
Message =
|
||||
{
|
||||
Result = false,
|
||||
Message =
|
||||
$"CRON {settings.RecentlyAddedCron} is not valid. Please ensure you are using a valid CRON."
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
var result = await ScheduledJobSettings.SaveSettingsAsync(settings);
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace PlexRequests.UI.Modules.Admin
|
|||
Cache = cache;
|
||||
RequestQueue = requestQueue;
|
||||
|
||||
Security.HasPermissionsResponse(Permissions.Administrator);
|
||||
Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);
|
||||
|
||||
Get["Index", "/faultqueue"] = x => Index();
|
||||
}
|
||||
|
|
|
@ -49,8 +49,8 @@ namespace PlexRequests.UI.Modules.Admin
|
|||
Cache = cache;
|
||||
SystemSettings = ss;
|
||||
|
||||
Security.HasPermissionsResponse(Permissions.Administrator);
|
||||
|
||||
Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);
|
||||
|
||||
Get["/status", true] = async (x, ct) => await Status();
|
||||
Post["/save", true] = async (x, ct) => await Save();
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ using System.Linq;
|
|||
using System.Threading;
|
||||
|
||||
using Nancy;
|
||||
using Nancy.Linker;
|
||||
using Nancy.Security;
|
||||
using Ninject;
|
||||
using PlexRequests.Core;
|
||||
|
@ -151,14 +152,14 @@ namespace PlexRequests.UI.Modules
|
|||
get
|
||||
{
|
||||
var userRepo = ServiceLocator.Instance.Resolve<IUserRepository>();
|
||||
return _security ?? (_security = new SecurityExtensions(userRepo, this));
|
||||
var linker = ServiceLocator.Instance.Resolve<IResourceLinker>();
|
||||
return _security ?? (_security = new SecurityExtensions(userRepo, this, linker));
|
||||
}
|
||||
}
|
||||
|
||||
private SecurityExtensions _security;
|
||||
|
||||
|
||||
|
||||
protected bool LoggedIn => Context?.CurrentUser != null;
|
||||
|
||||
protected string Culture { get; set; }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region Copyright
|
||||
// /************************************************************************
|
||||
// Copyright (c) 2016 Jamie Rees
|
||||
// File: UpdateCheckerModule.cs
|
||||
// File: LayoutModule.cs
|
||||
// Created By: Jamie Rees
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
|
@ -25,6 +25,7 @@
|
|||
// ************************************************************************/
|
||||
#endregion
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Nancy;
|
||||
|
@ -35,24 +36,29 @@ using PlexRequests.Core;
|
|||
using PlexRequests.Core.SettingModels;
|
||||
using PlexRequests.Core.StatusChecker;
|
||||
using PlexRequests.Helpers;
|
||||
using PlexRequests.Services.Interfaces;
|
||||
using PlexRequests.Services.Jobs;
|
||||
using PlexRequests.UI.Models;
|
||||
|
||||
namespace PlexRequests.UI.Modules
|
||||
{
|
||||
public class UpdateCheckerModule : BaseAuthModule
|
||||
public class LayoutModule : BaseAuthModule
|
||||
{
|
||||
public UpdateCheckerModule(ICacheProvider provider, ISettingsService<PlexRequestSettings> pr, ISettingsService<SystemSettings> settings) : base("updatechecker", pr)
|
||||
public LayoutModule(ICacheProvider provider, ISettingsService<PlexRequestSettings> pr, ISettingsService<SystemSettings> settings, IJobRecord rec) : base("layout", pr)
|
||||
{
|
||||
Cache = provider;
|
||||
SystemSettings = settings;
|
||||
Job = rec;
|
||||
|
||||
Get["/", true] = async (x,ct) => await CheckLatestVersion();
|
||||
Get["/cacher", true] = async (x,ct) => await CacherRunning();
|
||||
}
|
||||
|
||||
private ICacheProvider Cache { get; }
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private ISettingsService<SystemSettings> SystemSettings { get; }
|
||||
private IJobRecord Job { get; }
|
||||
|
||||
private async Task<Response> CheckLatestVersion()
|
||||
{
|
||||
|
@ -79,5 +85,35 @@ namespace PlexRequests.UI.Modules
|
|||
return Response.AsJson(new JsonUpdateAvailableModel { UpdateAvailable = false });
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<Response> CacherRunning()
|
||||
{
|
||||
try
|
||||
{
|
||||
var jobs = await Job.GetJobsAsync();
|
||||
|
||||
// Check to see if any are running
|
||||
var runningJobs = jobs.Where(x => x.Running);
|
||||
|
||||
// We only want the cachers
|
||||
var cacherJobs = runningJobs.Where(x =>
|
||||
x.Name.Equals(JobNames.CpCacher)
|
||||
|| x.Name.Equals(JobNames.EpisodeCacher)
|
||||
|| x.Name.Equals(JobNames.PlexChecker)
|
||||
|| x.Name.Equals(JobNames.SonarrCacher)
|
||||
|| x.Name.Equals(JobNames.SrCacher));
|
||||
|
||||
|
||||
return Response.AsJson(cacherJobs.Any()
|
||||
? new { CurrentlyRunning = true, IsAdmin}
|
||||
: new { CurrentlyRunning = false, IsAdmin });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Warn("Exception Thrown when attempting to check the status");
|
||||
Log.Warn(e);
|
||||
return Response.AsJson(new { CurrentlyRunning = false, IsAdmin });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -52,7 +52,7 @@ namespace PlexRequests.UI.Modules
|
|||
: base(pr)
|
||||
{
|
||||
UserMapper = m;
|
||||
Get["/login"] = _ =>
|
||||
Get["LocalLogin","/login"] = _ =>
|
||||
{
|
||||
if (LoggedIn)
|
||||
{
|
||||
|
|
|
@ -99,7 +99,7 @@ namespace PlexRequests.UI.Modules
|
|||
{
|
||||
Session["TempMessage"] = Resources.UI.UserLogin_IncorrectUserPass;
|
||||
var uri = Linker.BuildRelativeUri(Context, "UserLoginIndex");
|
||||
return Response.AsRedirect(uri.ToString()); // TODO Check this
|
||||
return Response.AsRedirect(uri.ToString());
|
||||
}
|
||||
|
||||
var authenticated = false;
|
||||
|
@ -112,7 +112,7 @@ namespace PlexRequests.UI.Modules
|
|||
Log.Debug("User is in denied list, not allowing them to authenticate");
|
||||
Session["TempMessage"] = Resources.UI.UserLogin_IncorrectUserPass;
|
||||
var uri = Linker.BuildRelativeUri(Context, "UserLoginIndex");
|
||||
return Response.AsRedirect(uri.ToString()); // TODO Check this
|
||||
return Response.AsRedirect(uri.ToString());
|
||||
}
|
||||
|
||||
var password = string.Empty;
|
||||
|
@ -178,7 +178,7 @@ namespace PlexRequests.UI.Modules
|
|||
{
|
||||
var uri = Linker.BuildRelativeUri(Context, "UserLoginIndex");
|
||||
Session["TempMessage"] = Resources.UI.UserLogin_IncorrectUserPass;
|
||||
return Response.AsRedirect(uri.ToString()); // TODO Check this
|
||||
return Response.AsRedirect(uri.ToString());
|
||||
}
|
||||
|
||||
var landingSettings = await LandingPageSettings.GetSettingsAsync();
|
||||
|
@ -192,7 +192,7 @@ namespace PlexRequests.UI.Modules
|
|||
}
|
||||
}
|
||||
var retVal = Linker.BuildRelativeUri(Context, "SearchIndex");
|
||||
return Response.AsRedirect(retVal.ToString()); // TODO Check this
|
||||
return Response.AsRedirect(retVal.ToString());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue