diff --git a/PlexRequests.UI/Modules/BaseModule.cs b/PlexRequests.UI/Modules/BaseModule.cs new file mode 100644 index 000000000..c2d631a0a --- /dev/null +++ b/PlexRequests.UI/Modules/BaseModule.cs @@ -0,0 +1,58 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: BaseModule.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; +using Nancy.Extensions; +using PlexRequests.UI.Models; + +namespace PlexRequests.UI.Modules +{ + public class BaseModule : NancyModule + { + // TODO get this working + public BaseModule() + { + //CheckAuth(); + } + + public BaseModule(string modulePath) : base(modulePath) + { + //CheckAuth(); + } + + + private void CheckAuth() + { + + if (Request?.Session?[SessionKeys.UsernameKey] == null) + { + Context.GetRedirect("~/userlogin"); + } + } + + } +} \ No newline at end of file diff --git a/PlexRequests.UI/Modules/SearchModule.cs b/PlexRequests.UI/Modules/SearchModule.cs index d645aec84..50c651066 100644 --- a/PlexRequests.UI/Modules/SearchModule.cs +++ b/PlexRequests.UI/Modules/SearchModule.cs @@ -41,7 +41,7 @@ using PlexRequests.UI.Models; namespace PlexRequests.UI.Modules { - public class SearchModule : NancyModule + public class SearchModule : BaseModule { public SearchModule(ICacheProvider cache, ISettingsService cpSettings) : base("search") { diff --git a/PlexRequests.UI/Modules/UserLoginModule.cs b/PlexRequests.UI/Modules/UserLoginModule.cs index 227f7778f..ec56f0d46 100644 --- a/PlexRequests.UI/Modules/UserLoginModule.cs +++ b/PlexRequests.UI/Modules/UserLoginModule.cs @@ -61,7 +61,7 @@ namespace PlexRequests.UI.Modules // Add to the session Request.Session[SessionKeys.UsernameKey] = username; - return Response.AsJson(""); + return Response.AsJson(new { Result = true }); } } } \ No newline at end of file diff --git a/PlexRequests.UI/PlexRequests.UI.csproj b/PlexRequests.UI/PlexRequests.UI.csproj index b85e0716c..109639f6d 100644 --- a/PlexRequests.UI/PlexRequests.UI.csproj +++ b/PlexRequests.UI/PlexRequests.UI.csproj @@ -146,6 +146,7 @@ + diff --git a/PlexRequests.UI/Views/Login/Index.cshtml b/PlexRequests.UI/Views/Login/Index.cshtml index 3ac18c097..bf28d7c6a 100644 --- a/PlexRequests.UI/Views/Login/Index.cshtml +++ b/PlexRequests.UI/Views/Login/Index.cshtml @@ -16,4 +16,5 @@ If you have not yet created an Admin account you can do here: Invalid Username or Password! -} \ No newline at end of file +} + diff --git a/PlexRequests.UI/Views/UserLogin/Index.cshtml b/PlexRequests.UI/Views/UserLogin/Index.cshtml index e1f1fa2ce..a9aa8707d 100644 --- a/PlexRequests.UI/Views/UserLogin/Index.cshtml +++ b/PlexRequests.UI/Views/UserLogin/Index.cshtml @@ -1,7 +1,44 @@ -
- Username + +
- Password + @if (Model.UsePassword) + { + + + }
- -
\ No newline at end of file + + + + + \ No newline at end of file diff --git a/PlexRequests.sln b/PlexRequests.sln index 2f492d98b..3e124c7ef 100644 --- a/PlexRequests.sln +++ b/PlexRequests.sln @@ -29,6 +29,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlexRequests.Core.Tests", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlexRequests.Helpers.Tests", "PlexRequests.Helpers.Tests\PlexRequests.Helpers.Tests.csproj", "{0E6395D3-B074-49E8-898D-0EB99E507E0E}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{EC46BEB4-AEC4-42AE-B1D5-6B32FEA8154A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -75,4 +77,9 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {A930E2CF-79E2-45F9-B06A-9A719A254CE4} = {EC46BEB4-AEC4-42AE-B1D5-6B32FEA8154A} + {FCFECD5D-47F6-454D-8692-E27A921BE655} = {EC46BEB4-AEC4-42AE-B1D5-6B32FEA8154A} + {0E6395D3-B074-49E8-898D-0EB99E507E0E} = {EC46BEB4-AEC4-42AE-B1D5-6B32FEA8154A} + EndGlobalSection EndGlobal