From 26dd67a441d251bef56c14d8058e7068e38e06af Mon Sep 17 00:00:00 2001 From: dkanada Date: Sun, 2 Feb 2020 00:09:18 +0900 Subject: [PATCH] change authentication flow --- .../Session/SessionManager.cs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index ec3e87573..659483a36 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -1379,20 +1379,16 @@ namespace Emby.Server.Implementations.Session user = _userManager.GetUserByName(request.Username); } - if (user != null) - { - // TODO: Move this to userManager? - if (!string.IsNullOrEmpty(request.DeviceId) - && !_deviceManager.CanAccessDevice(user, request.DeviceId)) - { - throw new SecurityException("User is not allowed access from this device."); - } - } - if (user == null) { AuthenticationFailed?.Invoke(this, new GenericEventArgs(request)); - throw new SecurityException("Invalid user or password entered."); + throw new SecurityException("Invalid username or password entered."); + } + + if (!string.IsNullOrEmpty(request.DeviceId) + && !_deviceManager.CanAccessDevice(user, request.DeviceId)) + { + throw new SecurityException("User is not allowed access from this device."); } if (enforcePassword)