mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-10 15:32:37 -07:00
Fixed an issue where there were some JS errors on the landing page settings and stopped us being redirected to the login sometimes as an admin
This commit is contained in:
parent
c235018e98
commit
2aebbe0259
3 changed files with 159 additions and 151 deletions
|
@ -118,9 +118,10 @@ namespace PlexRequests.UI.Helpers
|
|||
|
||||
public static IHtmlString LoadDateTimePickerAsset(this HtmlHelpers helper)
|
||||
{
|
||||
var startUrl = GetBaseUrl();
|
||||
var content = GetBaseUrl();
|
||||
|
||||
var sb = new StringBuilder();
|
||||
var startUrl = $"{content}/Content";
|
||||
sb.AppendLine($"<link rel=\"stylesheet\" href=\"{startUrl}/datepicker.min.css\" type=\"text/css\"/>");
|
||||
sb.AppendLine($"<script src=\"{startUrl}/bootstrap-datetimepicker.min.js\"></script>");
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace PlexRequests.UI.Modules
|
|||
{
|
||||
get
|
||||
{
|
||||
if (Context?.CurrentUser == null)
|
||||
if (!LoggedIn)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -130,6 +130,9 @@ namespace PlexRequests.UI.Modules
|
|||
return claims.Contains(UserClaims.Admin) || claims.Contains(UserClaims.PowerUser);
|
||||
}
|
||||
}
|
||||
|
||||
protected bool LoggedIn => Context?.CurrentUser != null;
|
||||
|
||||
protected string Culture { get; set; }
|
||||
protected const string CultureCookieName = "_culture";
|
||||
protected Response SetCookie()
|
||||
|
|
|
@ -30,6 +30,7 @@ using System.Dynamic;
|
|||
using Nancy;
|
||||
using Nancy.Authentication.Forms;
|
||||
using Nancy.Extensions;
|
||||
using Nancy.Linker;
|
||||
using Nancy.Responses.Negotiation;
|
||||
using Nancy.Security;
|
||||
|
||||
|
@ -42,20 +43,22 @@ namespace PlexRequests.UI.Modules
|
|||
{
|
||||
public class LoginModule : BaseModule
|
||||
{
|
||||
public LoginModule(ISettingsService<PlexRequestSettings> pr, ICustomUserMapper m) : base(pr)
|
||||
public LoginModule(ISettingsService<PlexRequestSettings> pr, ICustomUserMapper m, IResourceLinker linker) : base(pr)
|
||||
{
|
||||
UserMapper = m;
|
||||
Get["/login"] = _ =>
|
||||
{
|
||||
if (LoggedIn)
|
||||
{
|
||||
var url = linker.BuildRelativeUri(Context, "SearchIndex");
|
||||
return Response.AsRedirect(url.ToString());
|
||||
}
|
||||
dynamic model = new ExpandoObject();
|
||||
model.Redirect = Request.Query.redirect.Value ?? string.Empty;
|
||||
model.Errored = Request.Query.error.HasValue;
|
||||
var adminCreated = UserMapper.DoUsersExist();
|
||||
model.AdminExists = adminCreated;
|
||||
return View["Index", model];
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Get["/logout"] = x => this.LogoutAndRedirect(!string.IsNullOrEmpty(BaseUrl) ? $"~/{BaseUrl}/" : "~/");
|
||||
|
@ -80,7 +83,8 @@ namespace PlexRequests.UI.Modules
|
|||
}
|
||||
Session[SessionKeys.UsernameKey] = username;
|
||||
Session[SessionKeys.ClientDateTimeOffsetKey] = dtOffset;
|
||||
if(redirect.Contains("userlogin")){
|
||||
if (redirect.Contains("userlogin"))
|
||||
{
|
||||
redirect = !string.IsNullOrEmpty(BaseUrl) ? $"/{BaseUrl}/search" : "/search";
|
||||
}
|
||||
return this.LoginAndRedirect(userId.Value, expiry, redirect);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue