aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server.Implementations/Security
diff options
context:
space:
mode:
authorgnattu <gnattu@users.noreply.github.com>2024-08-05 10:58:22 -0400
committerBond_009 <bond.009@outlook.com>2024-08-05 10:58:22 -0400
commit22d8528d904e69a8e22ba0e6d43dcb58a54bdcf5 (patch)
tree66ee833b499e5ca4d1f1b55e316a2060081a0773 /Jellyfin.Server.Implementations/Security
parentd5fdb9c3a728ff8204c14c171ee4bdb3c992b02f (diff)
Backport pull request #11901 from jellyfin/release-10.9.z
Implement Device Cache to replace EFCoreSecondLevelCacheInterceptor Original-merge: b7bc0e1c96553675a490c0bd92a58ad9c5f0d0e1 Merged-by: joshuaboniface <joshua@boniface.me> Backported-by: Bond_009 <bond.009@outlook.com>
Diffstat (limited to 'Jellyfin.Server.Implementations/Security')
-rw-r--r--Jellyfin.Server.Implementations/Security/AuthorizationContext.cs15
1 files changed, 12 insertions, 3 deletions
diff --git a/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs b/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
index 6bda12c5b..2ae722982 100644
--- a/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
+++ b/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
@@ -4,7 +4,10 @@ using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
+using Jellyfin.Data.Queries;
+using Jellyfin.Extensions;
using MediaBrowser.Controller;
+using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net;
using Microsoft.AspNetCore.Http;
@@ -17,15 +20,18 @@ namespace Jellyfin.Server.Implementations.Security
{
private readonly IDbContextFactory<JellyfinDbContext> _jellyfinDbProvider;
private readonly IUserManager _userManager;
+ private readonly IDeviceManager _deviceManager;
private readonly IServerApplicationHost _serverApplicationHost;
public AuthorizationContext(
IDbContextFactory<JellyfinDbContext> jellyfinDb,
IUserManager userManager,
+ IDeviceManager deviceManager,
IServerApplicationHost serverApplicationHost)
{
_jellyfinDbProvider = jellyfinDb;
_userManager = userManager;
+ _deviceManager = deviceManager;
_serverApplicationHost = serverApplicationHost;
}
@@ -121,7 +127,11 @@ namespace Jellyfin.Server.Implementations.Security
var dbContext = await _jellyfinDbProvider.CreateDbContextAsync().ConfigureAwait(false);
await using (dbContext.ConfigureAwait(false))
{
- var device = await dbContext.Devices.FirstOrDefaultAsync(d => d.AccessToken == token).ConfigureAwait(false);
+ var device = _deviceManager.GetDevices(
+ new DeviceQuery
+ {
+ AccessToken = token
+ }).Items.FirstOrDefault();
if (device is not null)
{
@@ -178,8 +188,7 @@ namespace Jellyfin.Server.Implementations.Security
if (updateToken)
{
- dbContext.Devices.Update(device);
- await dbContext.SaveChangesAsync().ConfigureAwait(false);
+ await _deviceManager.UpdateDevice(device).ConfigureAwait(false);
}
}
else