mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 17:14:42 +01:00
update local pin feature
This commit is contained in:
@@ -1278,7 +1278,17 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>Task{SessionInfo}.</returns>
|
||||
public async Task<AuthenticationResult> AuthenticateNewSession(AuthenticationRequest request)
|
||||
public Task<AuthenticationResult> AuthenticateNewSession(AuthenticationRequest request)
|
||||
{
|
||||
return AuthenticateNewSessionInternal(request, true);
|
||||
}
|
||||
|
||||
public Task<AuthenticationResult> CreateNewSession(AuthenticationRequest request)
|
||||
{
|
||||
return AuthenticateNewSessionInternal(request, false);
|
||||
}
|
||||
|
||||
private async Task<AuthenticationResult> AuthenticateNewSessionInternal(AuthenticationRequest request, bool enforcePassword)
|
||||
{
|
||||
var user = _userManager.Users
|
||||
.FirstOrDefault(i => string.Equals(request.Username, i.Name, StringComparison.OrdinalIgnoreCase));
|
||||
@@ -1291,13 +1301,16 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
}
|
||||
}
|
||||
|
||||
var result = await _userManager.AuthenticateUser(request.Username, request.PasswordSha1, request.PasswordMd5, request.RemoteEndPoint).ConfigureAwait(false);
|
||||
|
||||
if (!result)
|
||||
if (enforcePassword)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(AuthenticationFailed, this, new GenericEventArgs<AuthenticationRequest>(request), _logger);
|
||||
var result = await _userManager.AuthenticateUser(request.Username, request.PasswordSha1, request.PasswordMd5, request.RemoteEndPoint).ConfigureAwait(false);
|
||||
|
||||
throw new SecurityException("Invalid user or password entered.");
|
||||
if (!result)
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(AuthenticationFailed, this, new GenericEventArgs<AuthenticationRequest>(request), _logger);
|
||||
|
||||
throw new SecurityException("Invalid user or password entered.");
|
||||
}
|
||||
}
|
||||
|
||||
var token = await GetAuthorizationToken(user.Id.ToString("N"), request.DeviceId, request.App, request.AppVersion, request.DeviceName).ConfigureAwait(false);
|
||||
@@ -1320,7 +1333,8 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
ServerId = _appHost.SystemId
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
private async Task<string> GetAuthorizationToken(string userId, string deviceId, string app, string appVersion, string deviceName)
|
||||
{
|
||||
var existing = _authRepo.Get(new AuthenticationInfoQuery
|
||||
|
||||
Reference in New Issue
Block a user