aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Session/SessionManager.cs
diff options
context:
space:
mode:
authorJoshua M. Boniface <joshua@boniface.me>2020-10-04 23:34:52 -0400
committerGitHub <noreply@github.com>2020-10-04 23:34:52 -0400
commit2a575dd67e9841719c6296ef606b69f16690829c (patch)
tree2c16848cee3439c3760a1f89a2730b276c7ee115 /Emby.Server.Implementations/Session/SessionManager.cs
parentd47284d59feb227c5eb00d2b52a3ad5e32f5ff87 (diff)
parentf2763a71e06c087c940f267313e24fb15dc13d37 (diff)
Merge pull request #4269 from joshuaboniface/session-limit
Add user max sessions options
Diffstat (limited to 'Emby.Server.Implementations/Session/SessionManager.cs')
-rw-r--r--Emby.Server.Implementations/Session/SessionManager.cs8
1 files changed, 8 insertions, 0 deletions
diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs
index e42d47853..fa4caeb18 100644
--- a/Emby.Server.Implementations/Session/SessionManager.cs
+++ b/Emby.Server.Implementations/Session/SessionManager.cs
@@ -1484,6 +1484,14 @@ namespace Emby.Server.Implementations.Session
throw new SecurityException("User is not allowed access from this device.");
}
+ int sessionsCount = Sessions.Count(i => i.UserId.Equals(user.Id));
+ int maxActiveSessions = user.MaxActiveSessions;
+ _logger.LogInformation("Current/Max sessions for user {User}: {Sessions}/{Max}", user.Username, sessionsCount, maxActiveSessions);
+ if (maxActiveSessions >= 1 && sessionsCount >= maxActiveSessions)
+ {
+ throw new SecurityException("User is at their maximum number of sessions.");
+ }
+
var token = GetAuthorizationToken(user, request.DeviceId, request.App, request.AppVersion, request.DeviceName);
var session = LogSessionActivity(