aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations')
-rw-r--r--MediaBrowser.Server.Implementations/Session/SessionManager.cs9
-rw-r--r--MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs8
2 files changed, 9 insertions, 8 deletions
diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs
index 76e97ff48..8a21ed6bd 100644
--- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs
+++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs
@@ -1687,16 +1687,11 @@ namespace MediaBrowser.Server.Implementations.Session
AccessToken = token
});
- if (result.Items.Length == 0)
- {
- return null;
- }
-
- var info = result.Items[0];
+ var info = result.Items.FirstOrDefault();
if (info == null)
{
- return null;
+ return Task.FromResult<SessionInfo>(null);
}
return GetSessionByAuthenticationToken(info, deviceId, remoteEndpoint, null);
diff --git a/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs b/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs
index dda4c2b90..b8cab0c19 100644
--- a/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs
+++ b/MediaBrowser.Server.Implementations/Session/SessionWebSocketListener.cs
@@ -85,7 +85,8 @@ namespace MediaBrowser.Server.Implementations.Session
async void _httpServer_WebSocketConnecting(object sender, WebSocketConnectingEventArgs e)
{
- if (e.QueryString.AllKeys.Contains("api_key", StringComparer.OrdinalIgnoreCase))
+ var token = e.QueryString["api_key"];
+ if (!string.IsNullOrWhiteSpace(token))
{
var session = await GetSession(e.QueryString, e.Endpoint).ConfigureAwait(false);
@@ -98,6 +99,11 @@ namespace MediaBrowser.Server.Implementations.Session
private Task<SessionInfo> GetSession(NameValueCollection queryString, string remoteEndpoint)
{
+ if (queryString == null)
+ {
+ throw new ArgumentNullException("queryString");
+ }
+
var token = queryString["api_key"];
if (string.IsNullOrWhiteSpace(token))
{