mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-10 15:32:37 -07:00
fixed #412
This commit is contained in:
parent
5bda83bfdf
commit
8854dc23c7
4 changed files with 279 additions and 277 deletions
|
@ -59,6 +59,10 @@
|
|||
<HintPath>..\packages\Nancy.1.4.3\lib\net40\Nancy.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Nancy.Linker, Version=0.3.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Nancy.Linker.0.3.1\lib\net40-Client\Nancy.Linker.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Nancy.Testing, Version=1.4.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Nancy.Testing.1.4.1\lib\net40\Nancy.Testing.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<package id="Microsoft.AspNet.Razor" version="2.0.30506.0" targetFramework="net46" />
|
||||
<package id="Moq" version="4.2.1510.2205" targetFramework="net452" />
|
||||
<package id="Nancy" version="1.4.3" targetFramework="net46" />
|
||||
<package id="Nancy.Linker" version="0.3.1" targetFramework="net46" />
|
||||
<package id="Nancy.Testing" version="1.4.1" targetFramework="net46" />
|
||||
<package id="Nancy.Validation.FluentValidation" version="1.4.1" targetFramework="net46" />
|
||||
<package id="Nancy.Viewengines.Razor" version="1.4.3" targetFramework="net46" />
|
||||
|
|
|
@ -24,7 +24,11 @@
|
|||
// 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;
|
||||
|
@ -34,16 +38,44 @@ namespace PlexRequests.UI.Modules
|
|||
{
|
||||
public class IndexModule : BaseAuthModule
|
||||
{
|
||||
public IndexModule(ISettingsService<PlexRequestSettings> pr) : base(pr)
|
||||
public IndexModule(ISettingsService<PlexRequestSettings> pr, ISettingsService<LandingPageSettings> l, IResourceLinker rl) : base(pr)
|
||||
{
|
||||
Get["/"] = x => Index();
|
||||
LandingPage = l;
|
||||
Linker = rl;
|
||||
Get["Index", "/", true] = async (x, ct) => await Index();
|
||||
|
||||
Get["/Index"] = x => Index();
|
||||
Get["/Index", true] = async (x, ct) => await Index();
|
||||
}
|
||||
private ISettingsService<LandingPageSettings> LandingPage { get; }
|
||||
private IResourceLinker Linker { get; }
|
||||
|
||||
public async Task<RedirectResponse> 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());
|
||||
}
|
||||
|
||||
public RedirectResponse Index()
|
||||
// After login
|
||||
if (string.IsNullOrEmpty(Username))
|
||||
{
|
||||
return Context.GetRedirect(!string.IsNullOrEmpty(BaseUrl) ? $"~/{BaseUrl}/search" : "~/search");
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<Negotiator> 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];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue