feat: Enhance admin user management system

- Add admin override capability to DELETE /api/auth/account endpoint
- Move /api/auth/users to admin-only with complete user fields (first_name, last_name, role, theme)
- Consolidate Bruno requests: remove duplicate List Users (Admin), merge Delete Account functionality
- Update all documentation to reflect enhanced capabilities
- Implement pgx 5 standards compliance with proper error handling

BREAKING CHANGES:
- /api/auth/users endpoint now requires admin role (was previously accessible)
- DELETE /api/auth/account accepts optional user_id parameter for admin deletion
This commit is contained in:
2026-01-27 13:36:11 -05:00
parent 9262a35f68
commit 71584c1b55
11 changed files with 345 additions and 52 deletions
+3 -3
View File
@@ -96,7 +96,7 @@ templ AdminProfile(user User) {
<div class="mb-6">
<h4 class="text-lg font-medium mb-3" style="color: var(--text-primary)">Username</h4>
<form hx-put="/api/user/username" hx-target="#username-result" hx-swap="innerHTML" hx-headers='{"Authorization": "Bearer " + localStorage.getItem("token")}' class="flex space-x-3 max-w-md">
<form hx-put="/api/auth/username" hx-target="#username-result" hx-swap="innerHTML" hx-headers='{"Authorization": "Bearer " + localStorage.getItem("token")}' class="flex space-x-3 max-w-md">
<input type="text" name="username" value={ user.Username } class="flex-1 px-3 py-2 border rounded" style="background-color: var(--bg-primary); color: var(--text-primary); border-color: var(--border)" required>
<button type="submit" class="btn-primary px-4 py-2 rounded">Update</button>
</form>
@@ -105,7 +105,7 @@ templ AdminProfile(user User) {
<div class="mb-6">
<h4 class="text-lg font-medium mb-3" style="color: var(--text-primary)">Email Address</h4>
<form hx-put="/api/user/email" hx-target="#email-result" hx-swap="innerHTML" hx-headers='{"Authorization": "Bearer " + localStorage.getItem("token")}' class="flex space-x-3 max-w-md">
<form hx-put="/api/auth/email" hx-target="#email-result" hx-swap="innerHTML" hx-headers='{"Authorization": "Bearer " + localStorage.getItem("token")}' class="flex space-x-3 max-w-md">
<input type="email" name="email" value={ user.Email } class="flex-1 px-3 py-2 border rounded" style="background-color: var(--bg-primary); color: var(--text-primary); border-color: var(--border)" required>
<button type="submit" class="btn-primary px-4 py-2 rounded">Update</button>
</form>
@@ -114,7 +114,7 @@ templ AdminProfile(user User) {
<div>
<h4 class="text-lg font-medium mb-3" style="color: var(--text-primary)">Change Password</h4>
<form hx-put="/api/user/password" hx-target="#password-result" hx-swap="innerHTML" hx-headers='{"Authorization": "Bearer " + localStorage.getItem("token")}' class="space-y-4 max-w-md">
<form hx-put="/api/auth/password" hx-target="#password-result" hx-swap="innerHTML" hx-headers='{"Authorization": "Bearer " + localStorage.getItem("token")}' class="space-y-4 max-w-md">
<div>
<label class="block text-sm font-medium mb-1" style="color: var(--text-secondary)">Current Password</label>
<input type="password" name="current_password" class="w-full px-3 py-2 border rounded" style="background-color: var(--bg-primary); color: var(--text-primary); border-color: var(--border)" required>