diff --git a/PlexRequests.UI/Modules/LandingPageModule.cs b/PlexRequests.UI/Modules/LandingPageModule.cs index 9468662e6..2d1625d56 100644 --- a/PlexRequests.UI/Modules/LandingPageModule.cs +++ b/PlexRequests.UI/Modules/LandingPageModule.cs @@ -28,6 +28,7 @@ using System; using System.Threading.Tasks; using Nancy; +using Nancy.Linker; using Nancy.Responses.Negotiation; using PlexRequests.Api.Interfaces; @@ -40,40 +41,45 @@ namespace PlexRequests.UI.Modules public class LandingPageModule : BaseModule { public LandingPageModule(ISettingsService settingsService, ISettingsService landing, - ISettingsService ps, IPlexApi pApi, ISettingsService auth) : base("landing", settingsService) + ISettingsService ps, IPlexApi pApi, ISettingsService auth, IResourceLinker linker) : base("landing", settingsService) { LandingSettings = landing; PlexSettings = ps; PlexApi = pApi; AuthSettings = auth; + Linker = linker; - Get["/", true] = async (x, ct) => await Index(); + Get["LandingPageIndex","/", true] = async (x, ct) => + { + var s = await LandingSettings.GetSettingsAsync(); + if (!s.BeforeLogin && string.IsNullOrEmpty(Username)) //We are signed in + { + var url = Linker.BuildAbsoluteUri(Context, "SearchIndex").ToString(); + return Response.AsRedirect(url); + } + + var model = new LandingPageViewModel + { + Enabled = s.Enabled, + Id = s.Id, + EnabledNoticeTime = s.EnabledNoticeTime, + NoticeEnable = s.NoticeEnable, + NoticeEnd = s.NoticeEnd, + NoticeMessage = s.NoticeMessage, + NoticeStart = s.NoticeStart, + ContinueUrl = s.BeforeLogin ? $"userlogin" : $"search" + }; + return View["Landing/Index", model]; + }; Get["/status", true] = async (x, ct) => await CheckStatus(); + } private ISettingsService LandingSettings { get; } private ISettingsService PlexSettings { get; } private ISettingsService AuthSettings { get; } private IPlexApi PlexApi { get; } - - private async Task Index() - { - - var s = await LandingSettings.GetSettingsAsync(); - var model = new LandingPageViewModel - { - Enabled = s.Enabled, - Id = s.Id, - EnabledNoticeTime = s.EnabledNoticeTime, - NoticeEnable = s.NoticeEnable, - NoticeEnd = s.NoticeEnd, - NoticeMessage = s.NoticeMessage, - NoticeStart = s.NoticeStart, - ContinueUrl = s.BeforeLogin ? $"userlogin" : $"search" - }; - - return View["Landing/Index", model]; - } + private IResourceLinker Linker { get; } private async Task CheckStatus() { diff --git a/PlexRequests.UI/Modules/SearchModule.cs b/PlexRequests.UI/Modules/SearchModule.cs index d1bd4ce85..b8d6506dc 100644 --- a/PlexRequests.UI/Modules/SearchModule.cs +++ b/PlexRequests.UI/Modules/SearchModule.cs @@ -102,7 +102,7 @@ namespace PlexRequests.UI.Modules RequestLimitRepo = rl; - Get["/", true] = async (x, ct) => await RequestLoad(); + Get["SearchIndex","/", true] = async (x, ct) => await RequestLoad(); Get["movie/{searchTerm}", true] = async (x, ct) => await SearchMovie((string)x.searchTerm); Get["tv/{searchTerm}", true] = async (x, ct) => await SearchTvShow((string)x.searchTerm); @@ -151,6 +151,7 @@ namespace PlexRequests.UI.Modules private async Task RequestLoad() { + var settings = await PrService.GetSettingsAsync(); return View["Search/Index", settings]; diff --git a/PlexRequests.UI/PlexRequests.UI.csproj b/PlexRequests.UI/PlexRequests.UI.csproj index 150f818c7..1084e40ee 100644 --- a/PlexRequests.UI/PlexRequests.UI.csproj +++ b/PlexRequests.UI/PlexRequests.UI.csproj @@ -65,6 +65,10 @@ ..\packages\Nancy.Bootstrappers.Ninject.1.4.1\lib\net40\Nancy.Bootstrappers.Ninject.dll True + + ..\packages\Nancy.Linker.0.3.1\lib\net40-Client\Nancy.Linker.dll + True + ..\packages\Nancy.Metadata.Modules.1.4.1\lib\net40\Nancy.Metadata.Modules.dll True diff --git a/PlexRequests.UI/packages.config b/PlexRequests.UI/packages.config index 365e6cd83..dff106e13 100644 --- a/PlexRequests.UI/packages.config +++ b/PlexRequests.UI/packages.config @@ -22,6 +22,7 @@ +