towerops/lib/towerops_web/live/org_live/index.html.heex
Graham McIntire c52f313e2d
1. User Authentication
- Full auth system with email/password (using phx.gen.auth)
  - Login, registration, password reset
  - Session management with remember-me functionality
  - Magic link login support

  2. Organization Management
  - Multi-tenant organization system
  - Organizations schema with unique slugs
  - Automatic organization creation when users register
  - Organization switcher UI at /orgs

  3. Membership System
  - Users can belong to multiple organizations
  - 4 permission levels: Owner, Admin, Member, Viewer
  - Complete permission matrix implemented
  - Join/leave organizations

  4. Invitation System
  - Email-based invitations with secure tokens
  - 7-day expiration on invites
  - Track who invited and who accepted

  5. Authorization
  - Full policy system (Organizations.Policy)
  - can?(membership, :action, :resource) helper
  - Enforced via plugs in router

  6. LiveView Pages
  - /orgs - List all your organizations
  - /orgs/new - Create new organization
  - /orgs/:slug - Organization dashboard (placeholder)

  7. Database Schema
  - users table
  - organizations table
  - organization_memberships table
  - organization_invitations table
  - All migrations run successfully
2025-12-21 13:31:59 -06:00

39 lines
1.3 KiB
Text

<.header>
{@page_title}
<:actions>
<.link navigate={~p"/orgs/new"} class="btn btn-primary">
<.icon name="hero-plus" class="w-5 h-5" /> New Organization
</.link>
</:actions>
</.header>
<div class="mt-8 grid gap-4 md:grid-cols-2 lg:grid-cols-3">
<div :for={org <- @organizations} class="card bg-base-100 shadow-xl">
<div class="card-body">
<h2 class="card-title">{org.name}</h2>
<p class="text-sm text-base-content/60">
{Enum.find(org.memberships, &(&1.user_id == @current_scope.user.id)).role
|> to_string()
|> String.capitalize()}
</p>
<div class="card-actions justify-end mt-4">
<.link navigate={~p"/orgs/#{org.slug}"} class="btn btn-primary">
Open
</.link>
</div>
</div>
</div>
</div>
<%= if @organizations == [] do %>
<div class="text-center py-12">
<.icon name="hero-building-office" class="mx-auto w-12 h-12 text-base-content/40" />
<h3 class="mt-2 text-sm font-semibold text-base-content">No organizations</h3>
<p class="mt-1 text-sm text-base-content/60">Get started by creating a new organization.</p>
<div class="mt-6">
<.link navigate={~p"/orgs/new"} class="btn btn-primary">
<.icon name="hero-plus" class="w-5 h-5" /> New Organization
</.link>
</div>
</div>
<% end %>