Show imported Seerr accounts while preserving linked-user deduplication
This commit is contained in:
+3
-11
@@ -1223,9 +1223,8 @@ def get_all_users() -> list[Dict[str, Any]]:
|
||||
"is_expired": _is_datetime_in_past(row[12]),
|
||||
}
|
||||
)
|
||||
# Admin user management uses Jellyfin as the source of truth for non-admin
|
||||
# user objects. Seerr rows are treated as enrichment-only and hidden
|
||||
# from admin/user-management views to avoid duplicate accounts in the UI.
|
||||
# Imported Seerr accounts must remain manageable. Prefer a Jellyfin/local
|
||||
# account when a linked duplicate exists, without hiding Seerr-only users.
|
||||
def _provider_rank(user: Dict[str, Any]) -> int:
|
||||
provider = str(user.get("auth_provider") or "local").strip().lower()
|
||||
if provider == "jellyfin":
|
||||
@@ -1236,14 +1235,7 @@ def get_all_users() -> list[Dict[str, Any]]:
|
||||
return 2
|
||||
return 2
|
||||
|
||||
visible_candidates = [
|
||||
user
|
||||
for user in all_rows
|
||||
if not (
|
||||
str(user.get("auth_provider") or "local").strip().lower() == "jellyseerr"
|
||||
and str(user.get("role") or "user").strip().lower() != "admin"
|
||||
)
|
||||
]
|
||||
visible_candidates = all_rows
|
||||
|
||||
visible_candidates.sort(
|
||||
key=lambda user: (
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import unittest
|
||||
from backend.app import db
|
||||
from backend.tests.test_backend_quality import TempDatabaseMixin
|
||||
|
||||
|
||||
class SeerrUserVisibilityTests(TempDatabaseMixin, unittest.TestCase):
|
||||
def test_seerr_only_users_are_visible(self):
|
||||
db.create_user('local-admin', 'test-password', role='admin')
|
||||
db.create_user('imported-member', 'jellyseerr-user', auth_provider='jellyseerr', jellyseerr_user_id=42)
|
||||
self.assertEqual({u['username'] for u in db.get_all_users()}, {'local-admin', 'imported-member'})
|
||||
|
||||
def test_linked_duplicate_prefers_jellyfin(self):
|
||||
db.create_user('member@example.com', 'jellyseerr-user', auth_provider='jellyseerr', jellyseerr_user_id=42)
|
||||
db.create_user('member', 'jellyfin-user', auth_provider='jellyfin', jellyseerr_user_id=42)
|
||||
users = db.get_all_users()
|
||||
self.assertEqual(len(users), 1)
|
||||
self.assertEqual(users[0]['username'], 'member')
|
||||
Reference in New Issue
Block a user