towerops/lib/towerops_web/live/admin/org_live/index.html.heex
Graham McIntire 853d548f82
Add superuser system with user impersonation for admin support
Implement comprehensive admin interface allowing designated superusers to view all users and organizations, impersonate users for debugging, and perform administrative operations. All superuser actions are tracked in audit logs for compliance.

Features:
- Superuser authentication with dedicated admin routes at /admin
- User impersonation with session state preservation
- Admin dashboard with system statistics
- User and organization management interfaces
- Comprehensive audit logging with IP tracking
- Visual impersonation banner with exit capability
- Security controls preventing self-impersonation and superuser-to-superuser impersonation

Database:
- Add is_superuser boolean field to users table
- Create audit_logs table for tracking sensitive operations
- Set graham@mcintire.me as initial superuser
2026-01-06 12:50:10 -06:00

27 lines
1,023 B
Text

<Layouts.admin flash={@flash}>
<div class="space-y-6">
<div>
<h1 class="text-2xl font-bold text-zinc-900">All Organizations</h1>
<p class="text-zinc-600">Manage organizations</p>
</div>
<div class="bg-white rounded-lg border border-zinc-200">
<.table id="organizations" rows={@organizations}>
<:col :let={org} label="Name">{org.name}</:col>
<:col :let={org} label="Slug">{org.slug}</:col>
<:col :let={org} label="Members">{length(org.memberships)}</:col>
<:col :let={org} label="Created">{Calendar.strftime(org.inserted_at, "%Y-%m-%d")}</:col>
<:col :let={org} label="">
<button
phx-click="delete_org"
phx-value-id={org.id}
data-confirm="Are you sure? This will delete all sites, equipment, and data for this organization."
class="text-sm text-red-600 hover:text-red-800"
>
Delete
</button>
</:col>
</.table>
</div>
</div>
</Layouts.admin>