Add clearer exceptions, warnings and docs

This commit is contained in:
Bond_009
2019-10-20 21:12:03 +02:00
parent fdb0c3a1df
commit fef35d0505
10 changed files with 63 additions and 57 deletions

View File

@@ -1388,27 +1388,28 @@ namespace Emby.Server.Implementations.Session
if (user != null)
{
// TODO: Move this to userManager?
if (!string.IsNullOrEmpty(request.DeviceId))
if (!string.IsNullOrEmpty(request.DeviceId)
&& !_deviceManager.CanAccessDevice(user, request.DeviceId))
{
if (!_deviceManager.CanAccessDevice(user, request.DeviceId))
{
throw new SecurityException("User is not allowed access from this device.");
}
throw new SecurityException("User is not allowed access from this device.");
}
}
if (enforcePassword)
{
var result = await _userManager.AuthenticateUser(request.Username, request.Password, request.PasswordSha1, request.RemoteEndPoint, true).ConfigureAwait(false);
user = await _userManager.AuthenticateUser(
request.Username,
request.Password,
request.PasswordSha1,
request.RemoteEndPoint,
true).ConfigureAwait(false);
}
if (result == null)
{
AuthenticationFailed?.Invoke(this, new GenericEventArgs<AuthenticationRequest>(request));
if (user == null)
{
AuthenticationFailed?.Invoke(this, new GenericEventArgs<AuthenticationRequest>(request));
throw new SecurityException("Invalid user or password entered.");
}
user = result;
throw new SecurityException("Invalid user or password entered.");
}
var token = GetAuthorizationToken(user, request.DeviceId, request.App, request.AppVersion, request.DeviceName);