diff --git a/PlexRequests.UI.Tests/PlexRequests.UI.Tests.csproj b/PlexRequests.UI.Tests/PlexRequests.UI.Tests.csproj index 5ec37a74a..6f1d1ffae 100644 --- a/PlexRequests.UI.Tests/PlexRequests.UI.Tests.csproj +++ b/PlexRequests.UI.Tests/PlexRequests.UI.Tests.csproj @@ -1,179 +1,183 @@ - - - - Debug - AnyCPU - {A930E2CF-79E2-45F9-B06A-9A719A254CE4} - Library - Properties - PlexRequests.UI.Tests - PlexRequests.UI.Tests - v4.6 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\CsQuery.1.3.3\lib\net40\CsQuery.dll - True - - - ..\packages\FluentScheduler.3.1.46\lib\net40\FluentScheduler.dll - True - - - ..\packages\FluentValidation.6.2.1.0\lib\Net45\FluentValidation.dll - True - - - - ..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll - True - - - ..\packages\Nancy.1.4.3\lib\net40\Nancy.dll - True - - - ..\packages\Nancy.Testing.1.4.1\lib\net40\Nancy.Testing.dll - True - - - ..\packages\Nancy.Validation.FluentValidation.1.4.1\lib\net40\Nancy.Validation.FluentValidation.dll - True - - - ..\packages\Nancy.Viewengines.Razor.1.4.3\lib\net40\Nancy.ViewEngines.Razor.dll - True - - - ..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll - True - - - ..\packages\NUnit.3.2.0\lib\net45\nunit.framework.dll - True - - - ..\packages\AutoFixture.3.40.0\lib\net40\Ploeh.AutoFixture.dll - True - - - - - ..\packages\Microsoft.AspNet.Razor.2.0.30506.0\lib\net40\System.Web.Razor.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - - - {95834072-A675-415D-AA8F-877C91623810} - PlexRequests.Api.Interfaces - - - {CB37A5F8-6DFC-4554-99D3-A42B502E4591} - PlexRequests.Api.Models - - - {DD7DC444-D3BF-4027-8AB9-EFC71F5EC581} - PlexRequests.Core - - - {1252336d-42a3-482a-804c-836e60173dfa} - PlexRequests.Helpers - - - {566EFA49-68F8-4716-9693-A6B3F2624DEA} - PlexRequests.Services - - - {92433867-2B7B-477B-A566-96C382427525} - PlexRequests.Store - - - {68F5F5F3-B8BB-4911-875F-6F00AAE04EA6} - PlexRequests.UI - - - - - - - False - - - False - - - False - - - False - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - + + + + Debug + AnyCPU + {A930E2CF-79E2-45F9-B06A-9A719A254CE4} + Library + Properties + PlexRequests.UI.Tests + PlexRequests.UI.Tests + v4.6 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\CsQuery.1.3.3\lib\net40\CsQuery.dll + True + + + ..\packages\FluentScheduler.3.1.46\lib\net40\FluentScheduler.dll + True + + + ..\packages\FluentValidation.6.2.1.0\lib\Net45\FluentValidation.dll + True + + + + ..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll + True + + + ..\packages\Nancy.1.4.3\lib\net40\Nancy.dll + True + + + ..\packages\Nancy.Linker.0.3.1\lib\net40-Client\Nancy.Linker.dll + True + + + ..\packages\Nancy.Testing.1.4.1\lib\net40\Nancy.Testing.dll + True + + + ..\packages\Nancy.Validation.FluentValidation.1.4.1\lib\net40\Nancy.Validation.FluentValidation.dll + True + + + ..\packages\Nancy.Viewengines.Razor.1.4.3\lib\net40\Nancy.ViewEngines.Razor.dll + True + + + ..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll + True + + + ..\packages\NUnit.3.2.0\lib\net45\nunit.framework.dll + True + + + ..\packages\AutoFixture.3.40.0\lib\net40\Ploeh.AutoFixture.dll + True + + + + + ..\packages\Microsoft.AspNet.Razor.2.0.30506.0\lib\net40\System.Web.Razor.dll + True + + + + + + + + + + + + + + + + + + + + + + + + + + + {95834072-A675-415D-AA8F-877C91623810} + PlexRequests.Api.Interfaces + + + {CB37A5F8-6DFC-4554-99D3-A42B502E4591} + PlexRequests.Api.Models + + + {DD7DC444-D3BF-4027-8AB9-EFC71F5EC581} + PlexRequests.Core + + + {1252336d-42a3-482a-804c-836e60173dfa} + PlexRequests.Helpers + + + {566EFA49-68F8-4716-9693-A6B3F2624DEA} + PlexRequests.Services + + + {92433867-2B7B-477B-A566-96C382427525} + PlexRequests.Store + + + {68F5F5F3-B8BB-4911-875F-6F00AAE04EA6} + PlexRequests.UI + + + + + + + False + + + False + + + False + + + False + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/PlexRequests.UI.Tests/packages.config b/PlexRequests.UI.Tests/packages.config index d4b45a263..f2bb0ecfa 100644 --- a/PlexRequests.UI.Tests/packages.config +++ b/PlexRequests.UI.Tests/packages.config @@ -1,15 +1,16 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PlexRequests.UI/Modules/IndexModule.cs b/PlexRequests.UI/Modules/IndexModule.cs index 80ed7947b..3d7023d39 100644 --- a/PlexRequests.UI/Modules/IndexModule.cs +++ b/PlexRequests.UI/Modules/IndexModule.cs @@ -1,49 +1,81 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: IndexModule.cs -// Created By: Jamie Rees -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// ************************************************************************/ -#endregion -using Nancy.Extensions; -using Nancy.Responses; - -using PlexRequests.Core; -using PlexRequests.Core.SettingModels; - -namespace PlexRequests.UI.Modules -{ - public class IndexModule : BaseAuthModule - { - public IndexModule(ISettingsService pr) : base(pr) - { - Get["/"] = x => Index(); - - Get["/Index"] = x => Index(); - } - - public RedirectResponse Index() - { - return Context.GetRedirect(!string.IsNullOrEmpty(BaseUrl) ? $"~/{BaseUrl}/search" : "~/search"); - } - } +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: IndexModule.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion +using System.Threading.Tasks; + +using Nancy; +using Nancy.Extensions; +using Nancy.Linker; +using Nancy.Responses; + +using PlexRequests.Core; +using PlexRequests.Core.SettingModels; + +namespace PlexRequests.UI.Modules +{ + public class IndexModule : BaseAuthModule + { + public IndexModule(ISettingsService pr, ISettingsService l, IResourceLinker rl) : base(pr) + { + LandingPage = l; + Linker = rl; + Get["Index", "/", true] = async (x, ct) => await Index(); + + Get["/Index", true] = async (x, ct) => await Index(); + } + private ISettingsService LandingPage { get; } + private IResourceLinker Linker { get; } + + public async Task Index() + { + var settings = await LandingPage.GetSettingsAsync(); + if (settings.Enabled) + { + if (settings.BeforeLogin) // Before login + { + if (!string.IsNullOrEmpty(Username)) + { + // They are not logged in + return Context.GetRedirect(Linker.BuildAbsoluteUri(Context, "LandingPageIndex").ToString()); + } + return Context.GetRedirect(Linker.BuildAbsoluteUri(Context, "SearchIndex").ToString()); + } + + // After login + if (string.IsNullOrEmpty(Username)) + { + // Not logged in yet + return Context.GetRedirect(Linker.BuildAbsoluteUri(Context, "UserLoginIndex").ToString()); + } + // Send them to landing + var landingUrl = Linker.BuildAbsoluteUri(Context, "LandingPageIndex").ToString(); + return Context.GetRedirect(landingUrl); + } + + return Context.GetRedirect(Linker.BuildAbsoluteUri(Context, "UserLoginIndex").ToString()); + } + } } \ No newline at end of file diff --git a/PlexRequests.UI/Modules/UserLoginModule.cs b/PlexRequests.UI/Modules/UserLoginModule.cs index fb0d5400d..430158e03 100644 --- a/PlexRequests.UI/Modules/UserLoginModule.cs +++ b/PlexRequests.UI/Modules/UserLoginModule.cs @@ -55,7 +55,7 @@ namespace PlexRequests.UI.Modules LandingPageSettings = lp; Analytics = a; Api = api; - Get["/", true] = async (x, ct) => await Index(); + Get["UserLoginIndex","/", true] = async (x, ct) => await Index(); Post["/"] = x => LoginUser(); Get["/logout"] = x => Logout(); } @@ -69,42 +69,7 @@ namespace PlexRequests.UI.Modules public async Task Index() { - var query = Request.Query["landing"]; - var landingCheck = (bool?)query ?? true; - if (landingCheck) - { - var landingSettings = await LandingPageSettings.GetSettingsAsync(); - - if (landingSettings.Enabled) - { - - if (landingSettings.BeforeLogin) - { -#pragma warning disable 4014 - Analytics.TrackEventAsync( -#pragma warning restore 4014 - Category.LandingPage, - Action.View, - "Going To LandingPage before login", - Username, - CookieHelper.GetAnalyticClientId(Cookies)); - - var model = new LandingPageViewModel - { - Enabled = landingSettings.Enabled, - Id = landingSettings.Id, - EnabledNoticeTime = landingSettings.EnabledNoticeTime, - NoticeEnable = landingSettings.NoticeEnable, - NoticeEnd = landingSettings.NoticeEnd, - NoticeMessage = landingSettings.NoticeMessage, - NoticeStart = landingSettings.NoticeStart, - ContinueUrl = landingSettings.BeforeLogin ? $"userlogin" : $"search" - }; - - return View["Landing/Index", model]; - } - } - } + var settings = await AuthService.GetSettingsAsync(); return View["Index", settings]; }