mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 18:47:15 -07:00
Fixed exception and all areas will now use the base url #72
This commit is contained in:
parent
866b6d6d6d
commit
6dea8b7440
7 changed files with 32 additions and 16 deletions
|
@ -56,7 +56,7 @@ using Nancy.Security;
|
|||
|
||||
namespace PlexRequests.UI.Modules
|
||||
{
|
||||
public class AdminModule : NancyModule
|
||||
public class AdminModule : BaseModule
|
||||
{
|
||||
private ISettingsService<PlexRequestSettings> PrService { get; }
|
||||
private ISettingsService<CouchPotatoSettings> CpService { get; }
|
||||
|
@ -181,8 +181,16 @@ namespace PlexRequests.UI.Modules
|
|||
var result = AuthService.SaveSettings(model);
|
||||
if (result)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(BaseUrl))
|
||||
{
|
||||
return Context.GetRedirect($"~/{BaseUrl}/admin/authentication");
|
||||
}
|
||||
return Context.GetRedirect("~/admin/authentication");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(BaseUrl))
|
||||
{
|
||||
return Context.GetRedirect($"~/{BaseUrl}/error"); //TODO create error page
|
||||
}
|
||||
return Context.GetRedirect("~/error"); //TODO create error page
|
||||
}
|
||||
|
||||
|
@ -201,8 +209,7 @@ namespace PlexRequests.UI.Modules
|
|||
|
||||
PrService.SaveSettings(model);
|
||||
|
||||
|
||||
return Context.GetRedirect("~/admin");
|
||||
return Context.GetRedirect(!string.IsNullOrEmpty(BaseUrl) ? $"~/{BaseUrl}/admin" : "~/admin");
|
||||
}
|
||||
|
||||
private Response RequestAuthToken()
|
||||
|
|
|
@ -35,10 +35,12 @@ namespace PlexRequests.UI.Modules
|
|||
public class BaseModule : NancyModule
|
||||
{
|
||||
protected ServiceLocator Locator => ServiceLocator.Instance;
|
||||
protected string BaseUrl { get; set; }
|
||||
public BaseModule()
|
||||
{
|
||||
var settings = Locator.Resolve<ISettingsService<PlexRequestSettings>>().GetSettings();
|
||||
var baseUrl = settings.BaseUrl;
|
||||
BaseUrl = baseUrl;
|
||||
|
||||
var modulePath = string.IsNullOrEmpty(baseUrl) ? string.Empty : baseUrl;
|
||||
|
||||
|
@ -49,6 +51,7 @@ namespace PlexRequests.UI.Modules
|
|||
{
|
||||
var settings = Locator.Resolve<ISettingsService<PlexRequestSettings>>().GetSettings();
|
||||
var baseUrl = settings.BaseUrl;
|
||||
BaseUrl = baseUrl;
|
||||
|
||||
var settingModulePath = string.IsNullOrEmpty(baseUrl) ? modulePath : $"{baseUrl}/{modulePath}";
|
||||
|
||||
|
|
|
@ -33,8 +33,9 @@ namespace PlexRequests.UI.Modules
|
|||
{
|
||||
public IndexModule()
|
||||
{
|
||||
Get["/"] = parameters => Context.GetRedirect("~/search");
|
||||
Get["/Index"] = parameters => Context.GetRedirect("~/search");
|
||||
Get["/"] = parameters => Context.GetRedirect(!string.IsNullOrEmpty(BaseUrl) ? $"~/{BaseUrl}/search" : "~/search");
|
||||
|
||||
Get["/Index"] = parameters => Context.GetRedirect(!string.IsNullOrEmpty(BaseUrl) ? $"~/{BaseUrl}/search" : "~/search");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -38,7 +38,7 @@ using PlexRequests.UI.Models;
|
|||
|
||||
namespace PlexRequests.UI.Modules
|
||||
{
|
||||
public class LoginModule : NancyModule
|
||||
public class LoginModule : BaseModule
|
||||
{
|
||||
public LoginModule()
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ namespace PlexRequests.UI.Modules
|
|||
|
||||
};
|
||||
|
||||
Get["/logout"] = x => this.LogoutAndRedirect("~/");
|
||||
Get["/logout"] = x => this.LogoutAndRedirect(!string.IsNullOrEmpty(BaseUrl) ? $"~/{BaseUrl}/" : "~/");
|
||||
|
||||
Post["/login"] = x =>
|
||||
{
|
||||
|
@ -66,7 +66,7 @@ namespace PlexRequests.UI.Modules
|
|||
|
||||
if (userId == null)
|
||||
{
|
||||
return Context.GetRedirect("~/login?error=true&username=" + username);
|
||||
return Context.GetRedirect(!string.IsNullOrEmpty(BaseUrl) ? $"~/{BaseUrl}/login?error=true&username=" + username : "~/login?error=true&username=" + username);
|
||||
}
|
||||
DateTime? expiry = null;
|
||||
if (Request.Form.RememberMe.HasValue)
|
||||
|
@ -94,7 +94,7 @@ namespace PlexRequests.UI.Modules
|
|||
var exists = UserMapper.DoUsersExist();
|
||||
if (exists)
|
||||
{
|
||||
return Context.GetRedirect("~/register?error=true");
|
||||
return Context.GetRedirect(!string.IsNullOrEmpty(BaseUrl) ? $"~/{BaseUrl}/register?error=true" : "~/register?error=true");
|
||||
}
|
||||
var userId = UserMapper.CreateUser(username, Request.Form.Password, new[] { "Admin" });
|
||||
Session[SessionKeys.UsernameKey] = username;
|
||||
|
|
|
@ -155,7 +155,9 @@ namespace PlexRequests.UI.Modules
|
|||
{
|
||||
Session.Delete(SessionKeys.UsernameKey);
|
||||
}
|
||||
return Context.GetRedirect("~/userlogin");
|
||||
return Context.GetRedirect(!string.IsNullOrEmpty(BaseUrl)
|
||||
? $"~/{BaseUrl}/userlogin"
|
||||
: "~/userlogin");
|
||||
}
|
||||
|
||||
private bool CheckIfUserIsOwner(string authToken, string userName)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue