enhance auth status endpoint to return detailed linked services for Discord users
This commit is contained in:
+38
-7
@@ -152,16 +152,47 @@ async def login_submit(request: Request):
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# GET /auth/status — check which services are linked
|
||||
# GET /auth/status — get all linked services for a Discord user
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@router.get("/status")
|
||||
@router.get("/Discord/status")
|
||||
async def auth_status(discord_id: int):
|
||||
"""Return which services this Discord user has linked."""
|
||||
services: dict[str, bool] = {}
|
||||
for svc_name in list_auth_services():
|
||||
services[svc_name] = auth_store.is_authenticated(discord_id, svc_name)
|
||||
return {"discord_id": discord_id, "services": services}
|
||||
"""
|
||||
Return all services linked to this Discord user with full details.
|
||||
|
||||
Response:
|
||||
{
|
||||
"discord_id": 123456789,
|
||||
"linked_services": {
|
||||
"jellyfin": {
|
||||
"external_user_id": "abc123",
|
||||
"external_name": "Tim",
|
||||
"linked_at": "2026-05-25T10:00:00",
|
||||
"credentials": {
|
||||
"token": "jwt...",
|
||||
"url": "http://jellyfin:8096",
|
||||
"user_id": "abc123"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
auths = auth_store.get_all_auths(discord_id)
|
||||
|
||||
linked_services: dict[str, dict] = {}
|
||||
for auth in auths:
|
||||
svc_name = auth["service"]
|
||||
linked_services[svc_name] = {
|
||||
"external_user_id": auth["external_user_id"],
|
||||
"external_name": auth["external_name"],
|
||||
"linked_at": auth["linked_at"],
|
||||
"credentials": auth["credentials"],
|
||||
}
|
||||
|
||||
return {
|
||||
"discord_id": discord_id,
|
||||
"linked_services": linked_services,
|
||||
}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user