feat(flow): auto-resolve authentik sub and improve admin dropdown UX
This commit is contained in:
@@ -12,6 +12,7 @@ from app.core.config import Settings
|
||||
class AuthentikSyncResult:
|
||||
user_id: int
|
||||
action: str
|
||||
authentik_sub: str | None = None
|
||||
|
||||
|
||||
class AuthentikAdminService:
|
||||
@@ -66,10 +67,14 @@ class AuthentikAdminService:
|
||||
patch_resp = client.patch(f"/api/v3/core/users/{user_pk}/", json=payload)
|
||||
if patch_resp.status_code >= 400:
|
||||
raise HTTPException(status_code=502, detail="authentik_update_failed")
|
||||
return AuthentikSyncResult(user_id=user_pk, action="updated")
|
||||
return AuthentikSyncResult(user_id=user_pk, action="updated", authentik_sub=existing.get("uid"))
|
||||
|
||||
create_resp = client.post("/api/v3/core/users/", json=payload)
|
||||
if create_resp.status_code >= 400:
|
||||
raise HTTPException(status_code=502, detail="authentik_create_failed")
|
||||
created = create_resp.json()
|
||||
return AuthentikSyncResult(user_id=int(created["pk"]), action="created")
|
||||
return AuthentikSyncResult(
|
||||
user_id=int(created["pk"]),
|
||||
action="created",
|
||||
authentik_sub=created.get("uid"),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user