From 8f3dbbc356eb6e0632a3396b4aa5bd0d6fb9f5e5 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 6 Apr 2019 19:31:08 -0700 Subject: [PATCH] Fixed: Return better error message if username or password is null for forms login --- src/NzbDrone.Core/Authentication/UserService.cs | 5 +++++ src/Sonarr.Http/Authentication/AuthenticationModule.cs | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Core/Authentication/UserService.cs b/src/NzbDrone.Core/Authentication/UserService.cs index 4ca713890..4e4bc9aed 100644 --- a/src/NzbDrone.Core/Authentication/UserService.cs +++ b/src/NzbDrone.Core/Authentication/UserService.cs @@ -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) diff --git a/src/Sonarr.Http/Authentication/AuthenticationModule.cs b/src/Sonarr.Http/Authentication/AuthenticationModule.cs index 3dd103602..cc4ea879a 100644 --- a/src/Sonarr.Http/Authentication/AuthenticationModule.cs +++ b/src/Sonarr.Http/Authentication/AuthenticationModule.cs @@ -3,7 +3,6 @@ using Nancy; using Nancy.Authentication.Forms; using Nancy.Extensions; using Nancy.ModelBinding; -using NzbDrone.Common.EnsureThat; using NzbDrone.Core.Authentication; using NzbDrone.Core.Configuration; @@ -24,9 +23,6 @@ namespace Sonarr.Http.Authentication private Response Login(LoginResource resource) { - Ensure.That(resource.Username, () => resource.Username).IsNotNullOrWhiteSpace(); - Ensure.That(resource.Password, () => resource.Password).IsNotNullOrWhiteSpace(); - var user = _userService.FindUser(resource.Username, resource.Password); if (user == null)