diff options
| author | Bill Thornton <billt2006@gmail.com> | 2023-09-11 10:49:01 -0400 |
|---|---|---|
| committer | Bill Thornton <billt2006@gmail.com> | 2023-09-11 10:49:01 -0400 |
| commit | 9ea46b9e17c82ae276d13d32647bf4c8d0c10ac3 (patch) | |
| tree | 4ab36cc7746c4f882052212f20b01a7e946bb8b1 | |
| parent | aea57c1a4a557d30c6169b530b6dccb0b0220b64 (diff) | |
Remove existing sessions for a user on the same device on login
| -rw-r--r-- | Emby.Server.Implementations/Session/SessionManager.cs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index bbc096a87..b4a622ccf 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -1509,14 +1509,20 @@ namespace Emby.Server.Implementations.Session new DeviceQuery { DeviceId = deviceId, - UserId = user.Id, - Limit = 1 - }).ConfigureAwait(false)).Items.FirstOrDefault(); + UserId = user.Id + }).ConfigureAwait(false)).Items; - if (existing is not null) + foreach (var auth in existing) { - _logger.LogInformation("Reusing existing access token: {Token}", existing.AccessToken); - return existing.AccessToken; + 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 existing session."); + } } _logger.LogInformation("Creating new access token for user {0}", user.Id); |
