Prevent orphaned user permissions and preferences (#17643)

Prevent orphaned user permissions and preferences
This commit is contained in:
m0g3r
2026-08-18 18:16:48 +02:00
committed by GitHub
parent 3fe35fcbc1
commit 46be43ad24
3 changed files with 26 additions and 0 deletions
@@ -225,12 +225,14 @@ namespace Jellyfin.Server.Implementations.Users
?? throw new ResourceNotFoundException(nameof(user.Id));
dbContext.Entry(dbUser).CurrentValues.SetValues(user);
dbContext.Permissions.RemoveRange(dbUser.Permissions);
dbUser.Permissions.Clear();
foreach (var permission in user.Permissions)
{
dbUser.Permissions.Add(new Permission(permission.Kind, permission.Value));
}
dbContext.Preferences.RemoveRange(dbUser.Preferences);
dbUser.Preferences.Clear();
foreach (var preference in user.Preferences)
{