diff options
| author | Luke <luke.pulverenti@gmail.com> | 2017-10-24 01:20:09 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-24 01:20:09 -0400 |
| commit | 0aac8045fb69ad1024859812a09e68070ea698f6 (patch) | |
| tree | 6e8b55133b0eeee606df5049497b80a612843733 /Emby.Server.Implementations/HttpServer/Security | |
| parent | 7924bb7c9add449f61d8695add6f2f3fcbc18a0a (diff) | |
| parent | 6c5f3ce07e8b36299a4143dc609999d880e7bdfd (diff) | |
Merge pull request #2974 from MediaBrowser/beta
Beta
Diffstat (limited to 'Emby.Server.Implementations/HttpServer/Security')
| -rw-r--r-- | Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs | 26 | ||||
| -rw-r--r-- | Emby.Server.Implementations/HttpServer/Security/SessionContext.cs | 9 |
2 files changed, 24 insertions, 11 deletions
diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs index c9d5ed007..a41c51d1a 100644 --- a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs +++ b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using MediaBrowser.Model.Services; using System.Linq; +using System.Threading; namespace Emby.Server.Implementations.HttpServer.Security { @@ -95,23 +96,44 @@ namespace Emby.Server.Implementations.HttpServer.Security { info.UserId = tokenInfo.UserId; + var updateToken = false; + // TODO: Remove these checks for IsNullOrWhiteSpace if (string.IsNullOrWhiteSpace(info.Client)) { info.Client = tokenInfo.AppName; } + + if (string.IsNullOrWhiteSpace(info.DeviceId)) + { + info.DeviceId = tokenInfo.DeviceId; + } + + if (string.IsNullOrWhiteSpace(info.Device)) { info.Device = tokenInfo.DeviceName; } - if (string.IsNullOrWhiteSpace(info.DeviceId)) + else if (!string.Equals(info.Device, tokenInfo.DeviceName, StringComparison.OrdinalIgnoreCase)) { - info.DeviceId = tokenInfo.DeviceId; + updateToken = true; + tokenInfo.DeviceName = info.Device; } + if (string.IsNullOrWhiteSpace(info.Version)) { info.Version = tokenInfo.AppVersion; } + else if (!string.Equals(info.Version, tokenInfo.AppVersion, StringComparison.OrdinalIgnoreCase)) + { + updateToken = true; + tokenInfo.AppVersion = info.Version; + } + + if (updateToken) + { + _authRepo.Update(tokenInfo, CancellationToken.None); + } } else { diff --git a/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs b/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs index dd5d64bf6..9826a0d56 100644 --- a/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs +++ b/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs @@ -25,15 +25,6 @@ namespace Emby.Server.Implementations.HttpServer.Security { var authorization = _authContext.GetAuthorizationInfo(requestContext); - //if (!string.IsNullOrWhiteSpace(authorization.Token)) - //{ - // var auth = GetTokenInfo(requestContext); - // if (auth != null) - // { - // return _sessionManager.GetSessionByAuthenticationToken(auth, authorization.DeviceId, requestContext.RemoteIp, authorization.Version); - // } - //} - var user = string.IsNullOrWhiteSpace(authorization.UserId) ? null : _userManager.GetUserById(authorization.UserId); return _sessionManager.LogSessionActivity(authorization.Client, authorization.Version, authorization.DeviceId, authorization.Device, requestContext.RemoteIp, user); } |
