diff --git a/PlexRequests.UI/Modules/BaseAuthModule.cs b/PlexRequests.UI/Modules/BaseAuthModule.cs index 675b1c170..5ddf39356 100644 --- a/PlexRequests.UI/Modules/BaseAuthModule.cs +++ b/PlexRequests.UI/Modules/BaseAuthModule.cs @@ -62,12 +62,14 @@ namespace PlexRequests.UI.Modules { return Context.GetRedirect(string.IsNullOrEmpty(baseUrl) ? "~/wizard" : $"~/{baseUrl}/wizard"); } - - var redirectPath = string.IsNullOrEmpty(baseUrl) ? "~/userlogin" : $"~/{baseUrl}/userlogin"; - - if (Session[SessionKeys.UsernameKey] == null && Context?.CurrentUser == null) + if (!Request.IsAjaxRequest()) { - return Context.GetRedirect(redirectPath); + var redirectPath = string.IsNullOrEmpty(baseUrl) ? "~/userlogin" : $"~/{baseUrl}/userlogin"; + + if (Session[SessionKeys.UsernameKey] == null && Context?.CurrentUser == null) + { + return Context.GetRedirect(redirectPath); + } } return null; diff --git a/PlexRequests.UI/Modules/IndexModule.cs b/PlexRequests.UI/Modules/IndexModule.cs index 65cfbaaff..96d62149c 100644 --- a/PlexRequests.UI/Modules/IndexModule.cs +++ b/PlexRequests.UI/Modules/IndexModule.cs @@ -59,7 +59,7 @@ namespace PlexRequests.UI.Modules { if (settings.BeforeLogin) // Before login { - if (!string.IsNullOrEmpty(Username)) + if (string.IsNullOrEmpty(Username)) { // They are not logged in return Context.GetRedirect(Linker.BuildRelativeUri(Context, "LandingPageIndex").ToString()); diff --git a/PlexRequests.UI/Modules/UserLoginModule.cs b/PlexRequests.UI/Modules/UserLoginModule.cs index 46a76de47..38635a1f1 100644 --- a/PlexRequests.UI/Modules/UserLoginModule.cs +++ b/PlexRequests.UI/Modules/UserLoginModule.cs @@ -41,12 +41,10 @@ using PlexRequests.Core.SettingModels; using PlexRequests.Core.Users; using PlexRequests.Helpers; using PlexRequests.Helpers.Analytics; -using PlexRequests.Helpers.Permissions; using PlexRequests.Store; using PlexRequests.Store.Models; using PlexRequests.Store.Repository; using PlexRequests.UI.Authentication; -using PlexRequests.UI.Helpers; using ISecurityExtensions = PlexRequests.Core.ISecurityExtensions; @@ -72,6 +70,34 @@ namespace PlexRequests.UI.Modules Get["UserLoginIndex", "/", true] = async (x, ct) => { + if (Request.Query["landing"] == null) + { + var s = await LandingPageSettings.GetSettingsAsync(); + if (s.Enabled) + { + if (s.BeforeLogin) // Before login + { + if (string.IsNullOrEmpty(Username)) + { + // They are not logged in + return + Context.GetRedirect(Linker.BuildRelativeUri(Context, "LandingPageIndex").ToString()); + } + return Context.GetRedirect(Linker.BuildRelativeUri(Context, "SearchIndex").ToString()); + } + + // After login + if (string.IsNullOrEmpty(Username)) + { + // Not logged in yet + return Context.GetRedirect(Linker.BuildRelativeUri(Context, "UserLoginIndex").ToString() + "?landing"); + } + // Send them to landing + var landingUrl = Linker.BuildRelativeUri(Context, "LandingPageIndex").ToString(); + return Context.GetRedirect(landingUrl); + } + } + if (!string.IsNullOrEmpty(Username) || IsAdmin) { var url = Linker.BuildRelativeUri(Context, "SearchIndex").ToString(); diff --git a/PlexRequests.UI/Views/Admin/Settings.cshtml b/PlexRequests.UI/Views/Admin/Settings.cshtml index b70d885f4..e1473d0f0 100644 --- a/PlexRequests.UI/Views/Admin/Settings.cshtml +++ b/PlexRequests.UI/Views/Admin/Settings.cshtml @@ -81,7 +81,7 @@ - @Html.Checkbox(Model.SearchForMovies,"SearchForMovies","Search for Movies"); + @Html.Checkbox(Model.SearchForMovies,"SearchForMovies","Search for Movies")
diff --git a/PlexRequests.UI/Views/Shared/Partial/_Navbar.cshtml b/PlexRequests.UI/Views/Shared/Partial/_Navbar.cshtml index 39352321b..6f1f45313 100644 --- a/PlexRequests.UI/Views/Shared/Partial/_Navbar.cshtml +++ b/PlexRequests.UI/Views/Shared/Partial/_Navbar.cshtml @@ -69,17 +69,18 @@ } @*@if (Context.Request.Session[SessionKeys.UsernameKey] != null && !Context.CurrentUser.IsAuthenticated())*@ - else if (Html.IsLoggedIn(Context)) // Logged in but not admin + else if (Context.CurrentUser != null && Context.CurrentUser.IsAuthenticated()) // Logged in but not admin { } +