mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 05:13:18 -07:00
More work for #298
This commit is contained in:
parent
0fa42b93f5
commit
05e4c313bf
7 changed files with 108 additions and 13 deletions
|
@ -65,11 +65,7 @@ namespace PlexRequests.UI.Modules
|
|||
return false;
|
||||
}
|
||||
var claims = Context.CurrentUser.Claims.ToList();
|
||||
if (claims.Contains(UserClaims.Admin) || claims.Contains(UserClaims.PowerUser))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return claims.Contains(UserClaims.Admin) || claims.Contains(UserClaims.PowerUser);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,7 +101,7 @@ namespace PlexRequests.UI.Modules
|
|||
var baseUrl = settings.BaseUrl;
|
||||
|
||||
var redirectPath = string.IsNullOrEmpty(baseUrl) ? "~/userlogin" : $"~/{baseUrl}/userlogin";
|
||||
|
||||
|
||||
return Session[SessionKeys.UsernameKey] == null
|
||||
? Context.GetRedirect(redirectPath)
|
||||
: null;
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ************************************************************************/
|
||||
#endregion
|
||||
using Nancy;
|
||||
using Nancy.Extensions;
|
||||
using Nancy.Responses;
|
||||
|
||||
using PlexRequests.Core;
|
||||
using PlexRequests.Core.SettingModels;
|
||||
|
@ -36,9 +36,14 @@ namespace PlexRequests.UI.Modules
|
|||
{
|
||||
public IndexModule(ISettingsService<PlexRequestSettings> pr) : base(pr)
|
||||
{
|
||||
Get["/"] = parameters => Context.GetRedirect(!string.IsNullOrEmpty(BaseUrl) ? $"~/{BaseUrl}/search" : "~/search");
|
||||
Get["/"] = x => Index();
|
||||
|
||||
Get["/Index"] = parameters => Context.GetRedirect(!string.IsNullOrEmpty(BaseUrl) ? $"~/{BaseUrl}/search" : "~/search");
|
||||
Get["/Index"] = x => Index();
|
||||
}
|
||||
|
||||
public RedirectResponse Index()
|
||||
{
|
||||
return Context.GetRedirect(!string.IsNullOrEmpty(BaseUrl) ? $"~/{BaseUrl}/search" : "~/search");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,9 +28,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Nancy;
|
||||
using Nancy.Extensions;
|
||||
using Nancy.Responses;
|
||||
using Nancy.Responses.Negotiation;
|
||||
|
||||
using NLog;
|
||||
|
@ -46,23 +48,30 @@ namespace PlexRequests.UI.Modules
|
|||
{
|
||||
public class UserLoginModule : BaseModule
|
||||
{
|
||||
public UserLoginModule(ISettingsService<AuthenticationSettings> auth, IPlexApi api, ISettingsService<PlexRequestSettings> pr) : base("userlogin", pr)
|
||||
public UserLoginModule(ISettingsService<AuthenticationSettings> auth, IPlexApi api, ISettingsService<PlexRequestSettings> pr, ISettingsService<LandingPageSettings> lp) : base("userlogin", pr)
|
||||
{
|
||||
AuthService = auth;
|
||||
LandingPageSettings = lp;
|
||||
Api = api;
|
||||
Get["/"] = _ => Index();
|
||||
Get["/", true] = async (x, ct) => await Index();
|
||||
Post["/"] = x => LoginUser();
|
||||
Get["/logout"] = x => Logout();
|
||||
}
|
||||
|
||||
private ISettingsService<AuthenticationSettings> AuthService { get; }
|
||||
private ISettingsService<LandingPageSettings> LandingPageSettings { get; }
|
||||
private IPlexApi Api { get; }
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public Negotiator Index()
|
||||
public async Task<Negotiator> Index()
|
||||
{
|
||||
var settings = AuthService.GetSettings();
|
||||
var landingSettings = await LandingPageSettings.GetSettingsAsync();
|
||||
if (landingSettings.Enabled)
|
||||
{
|
||||
return View["Landing/Index",landingSettings];
|
||||
}
|
||||
var settings = await AuthService.GetSettingsAsync();
|
||||
return View["Index", settings];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue