From 19c1ccb11c10698259fa01b408979b4fac158cd5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Mar 2026 20:03:03 +0000 Subject: [PATCH] fix(auth): restore get_user function body lost in refactor; fix button period placement - Restore the get_user handler that was accidentally dropped when inserting the local user management routes before the /{user_id:path} catch-all - Move period inside the 'Create one' button text in admin_users.html Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> --- app/api/admin_users.py | 32 +++++++++++++++++++++++++++++ frontend/templates/admin_users.html | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/app/api/admin_users.py b/app/api/admin_users.py index 0a4b7737..3134e99b 100644 --- a/app/api/admin_users.py +++ b/app/api/admin_users.py @@ -341,6 +341,38 @@ def delete_local_user(local_user_id: int, db: DbSession, _admin: AdminUser) -> N @router.get("/{user_id:path}", summary="Get details for a single user") +def get_user(user_id: str, db: DbSession, _admin: AdminUser) -> dict[str, Any]: + """Return profile and document statistics for a specific user.""" + doc_count = db.query(func.count(FileRecord.id)).filter(FileRecord.owner_id == user_id).scalar() or 0 + last_row = ( + db.query(FileRecord.created_at) + .filter(FileRecord.owner_id == user_id) + .order_by(FileRecord.created_at.desc()) + .first() + ) + last_upload = last_row[0].isoformat() if last_row and last_row[0] else None + + profile = _get_or_none(db, user_id) + + return { + "user_id": user_id, + "display_name": profile.display_name if profile else None, + "daily_upload_limit": profile.daily_upload_limit if profile else None, + "notes": profile.notes if profile else None, + "is_blocked": profile.is_blocked if profile else False, + "subscription_tier": (profile.subscription_tier or "free") if profile else "free", + "subscription_billing_cycle": (profile.subscription_billing_cycle or "monthly") if profile else "monthly", + "subscription_period_start": profile.subscription_period_start.isoformat() + if (profile and profile.subscription_period_start) + else None, + "allow_overage": bool(profile.allow_overage) if profile else False, + "profile_id": profile.id if profile else None, + "document_count": doc_count, + "last_upload": last_upload, + "profile": _profile_to_dict(profile) if profile else None, + } + + @router.put("/{user_id:path}", summary="Create or update a user profile") def upsert_user_profile( user_id: str, diff --git a/frontend/templates/admin_users.html b/frontend/templates/admin_users.html index 04b87b44..c2ffa15b 100644 --- a/frontend/templates/admin_users.html +++ b/frontend/templates/admin_users.html @@ -451,7 +451,7 @@ No local accounts yet. - . +