Moved the plex auth token to the plex settings where it should belong.

This commit is contained in:
tidusjar 2016-07-14 13:01:07 +01:00
parent ffe6bc41ac
commit 57ec940d5a
18 changed files with 2753 additions and 2837 deletions

View file

@ -29,7 +29,6 @@ using System.Threading.Tasks;
using Nancy;
using Nancy.Linker;
using Nancy.Responses.Negotiation;
using PlexRequests.Api.Interfaces;
using PlexRequests.Core;
@ -41,12 +40,11 @@ namespace PlexRequests.UI.Modules
public class LandingPageModule : BaseModule
{
public LandingPageModule(ISettingsService<PlexRequestSettings> settingsService, ISettingsService<LandingPageSettings> landing,
ISettingsService<PlexSettings> ps, IPlexApi pApi, ISettingsService<AuthenticationSettings> auth, IResourceLinker linker) : base("landing", settingsService)
ISettingsService<PlexSettings> ps, IPlexApi pApi, IResourceLinker linker) : base("landing", settingsService)
{
LandingSettings = landing;
PlexSettings = ps;
PlexApi = pApi;
AuthSettings = auth;
Linker = linker;
Get["LandingPageIndex","/", true] = async (x, ct) =>
@ -77,21 +75,19 @@ namespace PlexRequests.UI.Modules
private ISettingsService<LandingPageSettings> LandingSettings { get; }
private ISettingsService<PlexSettings> PlexSettings { get; }
private ISettingsService<AuthenticationSettings> AuthSettings { get; }
private IPlexApi PlexApi { get; }
private IResourceLinker Linker { get; }
private async Task<Response> CheckStatus()
{
var auth = await AuthSettings.GetSettingsAsync();
var plexSettings = await PlexSettings.GetSettingsAsync();
if (string.IsNullOrEmpty(auth.PlexAuthToken) || string.IsNullOrEmpty(plexSettings.Ip))
if (string.IsNullOrEmpty(plexSettings.PlexAuthToken) || string.IsNullOrEmpty(plexSettings.Ip))
{
return Response.AsJson(false);
}
try
{
var status = PlexApi.GetStatus(auth.PlexAuthToken, plexSettings.FullUri);
var status = PlexApi.GetStatus(plexSettings.PlexAuthToken, plexSettings.FullUri);
return Response.AsJson(status != null);
}
catch (Exception)