mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-26 15:52:42 +00:00
Fixed: Don't Error to New Page on Failed Login
This commit is contained in:
parent
d81b063388
commit
9d27fff825
1 changed files with 15 additions and 5 deletions
|
@ -4,6 +4,7 @@
|
|||
using Nancy.Extensions;
|
||||
using Nancy.ModelBinding;
|
||||
using NzbDrone.Common.EnsureThat;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Authentication;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
||||
|
@ -24,16 +25,19 @@ public AuthenticationModule(IUserService userService, IConfigFileProvider config
|
|||
|
||||
private Response Login(LoginResource resource)
|
||||
{
|
||||
Ensure.That(resource.Username, () => resource.Username).IsNotNullOrWhiteSpace();
|
||||
var username = resource.Username;
|
||||
var password = resource.Password;
|
||||
|
||||
Ensure.That(resource.Password, () => resource.Password).IsNotNullOrWhiteSpace();
|
||||
if (username.IsNullOrWhiteSpace() || password.IsNullOrWhiteSpace())
|
||||
{
|
||||
return LoginFailed();
|
||||
}
|
||||
|
||||
var user = _userService.FindUser(resource.Username, resource.Password);
|
||||
var user = _userService.FindUser(username, password);
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
var returnUrl = (string)Request.Query.returnUrl;
|
||||
return Context.GetRedirect($"~/login?returnUrl={returnUrl}&loginFailed=true");
|
||||
return LoginFailed();
|
||||
}
|
||||
|
||||
DateTime? expiry = null;
|
||||
|
@ -50,5 +54,11 @@ private Response Logout()
|
|||
{
|
||||
return this.LogoutAndRedirect(_configFileProvider.UrlBase + "/");
|
||||
}
|
||||
|
||||
private Response LoginFailed()
|
||||
{
|
||||
var returnUrl = (string)Request.Query.returnUrl;
|
||||
return Context.GetRedirect($"~/login?returnUrl={returnUrl}&loginFailed=true");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue