62 lines
2 KiB
Elixir
62 lines
2 KiB
Elixir
defmodule MvWeb.SignOutLive do
|
|
@moduledoc """
|
|
Custom sign-out confirmation page.
|
|
|
|
Replaces AshAuthentication.Phoenix.SignOutLive so the page meets accessibility
|
|
requirements (main landmark via Layouts.public_page, level-one heading) and
|
|
uses the project's DaisyUI button styles. Submits DELETE /sign-out for CSRF
|
|
protection, same contract as the library default.
|
|
"""
|
|
use Phoenix.LiveView
|
|
use Gettext, backend: MvWeb.Gettext
|
|
|
|
alias Mv.Membership
|
|
alias MvWeb.Layouts
|
|
|
|
@impl true
|
|
def mount(_params, session, socket) do
|
|
locale = session["locale"] || Application.get_env(:mv, :default_locale, "de")
|
|
_ = Gettext.put_locale(MvWeb.Gettext, locale)
|
|
_ = Gettext.put_locale(locale)
|
|
|
|
club_name =
|
|
case Membership.get_settings() do
|
|
{:ok, settings} when is_binary(settings.club_name) -> settings.club_name
|
|
_ -> nil
|
|
end
|
|
|
|
socket =
|
|
socket
|
|
|> assign(:sign_out_path, session["sign_out_path"] || "/sign-out")
|
|
|> assign(:locale, locale)
|
|
|> assign(:club_name, club_name)
|
|
|> Layouts.assign_page_title(dgettext("auth", "Sign out"))
|
|
|
|
{:ok, socket}
|
|
end
|
|
|
|
@impl true
|
|
def render(assigns) do
|
|
~H"""
|
|
<Layouts.public_page flash={@flash} club_name={@club_name}>
|
|
<div class="hero min-h-[40vh] bg-base-200 rounded-lg">
|
|
<div class="hero-content flex-col items-start text-left">
|
|
<div class="w-full max-w-md">
|
|
<h1 class="text-xl font-semibold leading-8 mb-4">
|
|
{dgettext("auth", "Sign out")}
|
|
</h1>
|
|
<p class="text-base-content/70 mb-4">
|
|
{dgettext("auth", "Are you sure you want to sign out?")}
|
|
</p>
|
|
<.form for={%{}} action={@sign_out_path} method="delete">
|
|
<button type="submit" class="btn btn-primary w-full">
|
|
{dgettext("auth", "Sign out")}
|
|
</button>
|
|
</.form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</Layouts.public_page>
|
|
"""
|
|
end
|
|
end
|