80 lines
2.5 KiB
Elixir
80 lines
2.5 KiB
Elixir
defmodule MvWeb.UserLive.Show do
|
|
@moduledoc """
|
|
LiveView for displaying a single user's details.
|
|
|
|
## Features
|
|
- Display user information (email, OIDC ID)
|
|
- Show authentication methods (password, OIDC)
|
|
- Display linked member account (if exists)
|
|
- Navigate to edit form
|
|
- Return to user list
|
|
|
|
## Displayed Information
|
|
- Email address
|
|
- OIDC ID (if authenticated via OIDC)
|
|
- Password authentication status
|
|
- Linked member (name and email)
|
|
|
|
## Authentication Status
|
|
Shows which authentication methods are enabled for the user:
|
|
- Password authentication (has hashed_password)
|
|
- OIDC authentication (has oidc_id)
|
|
|
|
## Navigation
|
|
- Back to user list
|
|
- Edit user (with return_to parameter for back navigation)
|
|
"""
|
|
use MvWeb, :live_view
|
|
|
|
@impl true
|
|
def render(assigns) do
|
|
~H"""
|
|
<Layouts.app flash={@flash} current_user={@current_user}>
|
|
<.header>
|
|
{gettext("User")} {@user.email}
|
|
<:subtitle>{gettext("This is a user record from your database.")}</:subtitle>
|
|
|
|
<:actions>
|
|
<.button navigate={~p"/users"} aria-label={gettext("Back to users list")}>
|
|
<.icon name="hero-arrow-left" />
|
|
<span class="sr-only">{gettext("Back to users list")}</span>
|
|
</.button>
|
|
<.button variant="primary" navigate={~p"/users/#{@user}/edit?return_to=show"}>
|
|
<.icon name="hero-pencil-square" /> {gettext("Edit User")}
|
|
</.button>
|
|
</:actions>
|
|
</.header>
|
|
|
|
<.list>
|
|
<:item title={gettext("Email")}>{@user.email}</:item>
|
|
<:item title={gettext("Password Authentication")}>
|
|
{if @user.hashed_password, do: gettext("Enabled"), else: gettext("Not enabled")}
|
|
</:item>
|
|
<:item title={gettext("Linked Member")}>
|
|
<%= if @user.member do %>
|
|
<.link
|
|
navigate={~p"/members/#{@user.member}"}
|
|
class="text-blue-600 underline hover:text-blue-800"
|
|
>
|
|
<.icon name="hero-users" class="inline w-4 h-4 mr-1" />
|
|
{@user.member.first_name} {@user.member.last_name}
|
|
</.link>
|
|
<% else %>
|
|
<span class="italic text-gray-500">{gettext("No member linked")}</span>
|
|
<% end %>
|
|
</:item>
|
|
</.list>
|
|
</Layouts.app>
|
|
"""
|
|
end
|
|
|
|
@impl true
|
|
def mount(%{"id" => id}, _session, socket) do
|
|
user = Ash.get!(Mv.Accounts.User, id, domain: Mv.Accounts, load: [:member])
|
|
|
|
{:ok,
|
|
socket
|
|
|> assign(:page_title, gettext("Show User"))
|
|
|> assign(:user, user)}
|
|
end
|
|
end
|