Merge pull request #10197 from thornbill/multiple-sessions

Remove one session per device id limitation
pull/10217/head
Claus Vium 1 year ago committed by GitHub
commit a35a74ce38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1509,36 +1509,21 @@ namespace Emby.Server.Implementations.Session
new DeviceQuery
{
DeviceId = deviceId,
UserId = user.Id,
Limit = 1
}).ConfigureAwait(false)).Items.FirstOrDefault();
var allExistingForDevice = (await _deviceManager.GetDevices(
new DeviceQuery
{
DeviceId = deviceId
UserId = user.Id
}).ConfigureAwait(false)).Items;
foreach (var auth in allExistingForDevice)
{
if (existing is null || !string.Equals(auth.AccessToken, existing.AccessToken, StringComparison.Ordinal))
foreach (var auth in existing)
{
try
{
// Logout any existing sessions for the user on this device
await Logout(auth).ConfigureAwait(false);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error while logging out.");
_logger.LogError(ex, "Error while logging out existing session.");
}
}
}
if (existing is not null)
{
_logger.LogInformation("Reissuing access token: {Token}", existing.AccessToken);
return existing.AccessToken;
}
_logger.LogInformation("Creating new access token for user {0}", user.Id);
var device = await _deviceManager.CreateDevice(new Device(user.Id, app, appVersion, deviceName, deviceId)).ConfigureAwait(false);

Loading…
Cancel
Save