mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-18 08:06:35 +00:00
Merge pull request #4269 from joshuaboniface/session-limit
Add user max sessions options
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user