1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2025-03-13 07:23:14 +00:00

Fixed: Return better error message if username or password is null

Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
This commit is contained in:
Qstick 2019-09-10 21:24:17 -04:00
parent dd014b1f52
commit 94f51cf124
2 changed files with 7 additions and 11 deletions

View file

@ -3,10 +3,6 @@ using Nancy;
using Nancy.Authentication.Forms;
using Nancy.Extensions;
using Nancy.ModelBinding;
using NzbDrone.Common.Extensions;
using NLog;
using NzbDrone.Common.Instrumentation;
using NzbDrone.Core.Authentication;
using NzbDrone.Core.Configuration;
namespace Lidarr.Http.Authentication
@ -30,7 +26,8 @@ namespace Lidarr.Http.Authentication
if (user == null)
{
return LoginFailed();
var returnUrl = (string)Request.Query.returnUrl;
return Context.GetRedirect($"~/login?returnUrl={returnUrl}&loginFailed=true");
}
DateTime? expiry = null;
@ -49,11 +46,5 @@ namespace Lidarr.Http.Authentication
return this.LogoutAndRedirect(_configFileProvider.UrlBase + "/");
}
private Response LoginFailed()
{
var returnUrl = (string)Request.Query.returnUrl;
return Context.GetRedirect($"~/login?returnUrl={returnUrl}&loginFailed=true");
}
}
}

View file

@ -73,6 +73,11 @@ namespace NzbDrone.Core.Authentication
public User FindUser(string username, string password)
{
if (username.IsNullOrWhiteSpace() || password.IsNullOrWhiteSpace())
{
return null;
}
var user = _repo.FindUser(username.ToLowerInvariant());
if (user == null)