aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Emby.Server.Implementations/Session/SessionManager.cs2
-rw-r--r--Jellyfin.Api/Controllers/DevicesController.cs6
-rw-r--r--Jellyfin.Server.Implementations/Devices/DeviceManager.cs6
-rw-r--r--Jellyfin.Server.Implementations/Security/AuthorizationContext.cs11
-rw-r--r--Jellyfin.Server/CoreAppHost.cs3
5 files changed, 10 insertions, 18 deletions
diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs
index 9dada44cb..ea710013e 100644
--- a/Emby.Server.Implementations/Session/SessionManager.cs
+++ b/Emby.Server.Implementations/Session/SessionManager.cs
@@ -535,7 +535,7 @@ namespace Emby.Server.Implementations.Session
}
var deviceOptions = await _deviceManager.GetDeviceOptions(deviceId).ConfigureAwait(false);
- if (string.IsNullOrEmpty(deviceOptions?.CustomName))
+ if (string.IsNullOrEmpty(deviceOptions.CustomName))
{
sessionInfo.DeviceName = deviceName;
}
diff --git a/Jellyfin.Api/Controllers/DevicesController.cs b/Jellyfin.Api/Controllers/DevicesController.cs
index d4c2dbba0..26b9a854d 100644
--- a/Jellyfin.Api/Controllers/DevicesController.cs
+++ b/Jellyfin.Api/Controllers/DevicesController.cs
@@ -107,12 +107,6 @@ namespace Jellyfin.Api.Controllers
[FromQuery, Required] string id,
[FromBody, Required] DeviceOptions deviceOptions)
{
- var existingDeviceOptions = await _deviceManager.GetDeviceOptions(id).ConfigureAwait(false);
- if (existingDeviceOptions == null)
- {
- return NotFound();
- }
-
await _deviceManager.UpdateDeviceOptions(id, deviceOptions).ConfigureAwait(false);
return NoContent();
}
diff --git a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs
index 86706cac9..ef0d5db09 100644
--- a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs
+++ b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs
@@ -74,13 +74,15 @@ namespace Jellyfin.Server.Implementations.Devices
}
/// <inheritdoc />
- public async Task<DeviceOptions?> GetDeviceOptions(string deviceId)
+ public async Task<DeviceOptions> GetDeviceOptions(string deviceId)
{
await using var dbContext = _dbProvider.CreateContext();
- return await dbContext.DeviceOptions
+ var deviceOptions = await dbContext.DeviceOptions
.AsQueryable()
.FirstOrDefaultAsync(d => d.DeviceId == deviceId)
.ConfigureAwait(false);
+
+ return deviceOptions ?? new DeviceOptions(deviceId);
}
/// <inheritdoc />
diff --git a/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs b/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
index 08970f84d..8a5d513ef 100644
--- a/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
+++ b/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
@@ -171,15 +171,7 @@ namespace Jellyfin.Server.Implementations.Security
updateToken = true;
}
- if (!device.UserId.Equals(Guid.Empty))
- {
- authInfo.User = _userManager.GetUserById(device.UserId);
- authInfo.IsApiKey = false;
- }
- else
- {
- authInfo.IsApiKey = true;
- }
+ authInfo.User = _userManager.GetUserById(device.UserId);
if (updateToken)
{
@@ -198,6 +190,7 @@ namespace Jellyfin.Server.Implementations.Security
authInfo.DeviceId = string.Empty;
authInfo.Device = string.Empty;
authInfo.Version = string.Empty;
+ authInfo.IsApiKey = true;
}
}
diff --git a/Jellyfin.Server/CoreAppHost.cs b/Jellyfin.Server/CoreAppHost.cs
index e480b9a69..d41b5f74e 100644
--- a/Jellyfin.Server/CoreAppHost.cs
+++ b/Jellyfin.Server/CoreAppHost.cs
@@ -20,6 +20,7 @@ using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net;
+using MediaBrowser.Controller.Security;
using MediaBrowser.Model.Activity;
using MediaBrowser.Model.IO;
using Microsoft.EntityFrameworkCore;
@@ -97,6 +98,8 @@ namespace Jellyfin.Server
ServiceCollection.AddSingleton<IAuthorizationContext, AuthorizationContext>();
+ ServiceCollection.AddScoped<IAuthenticationManager, AuthenticationManager>();
+
base.RegisterServices();
}