fix(auth): replace sign-out page with accessible custom LiveView
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/promote/production Build is passing

This commit is contained in:
Moritz 2026-06-01 20:06:32 +02:00
parent ba66bc15db
commit a27425b5fb
5 changed files with 93 additions and 1 deletions

View file

@ -0,0 +1,62 @@
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

View file

@ -112,7 +112,7 @@ defmodule MvWeb.Router do
# ASHAUTHENTICATION GENERATED AUTH ROUTES
auth_routes AuthController, Mv.Accounts.User, path: "/auth"
sign_out_route AuthController
sign_out_route AuthController, "/sign-out", live_view: MvWeb.SignOutLive
# Remove these if you'd like to use your own authentication views
sign_in_route register_path: "/register",

View file

@ -152,3 +152,13 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "Register"
msgstr ""
#: lib/mv_web/live/auth/sign_out_live.ex
#, elixir-autogen, elixir-format
msgid "Are you sure you want to sign out?"
msgstr ""
#: lib/mv_web/live/auth/sign_out_live.ex
#, elixir-autogen, elixir-format
msgid "Sign out"
msgstr ""

View file

@ -148,3 +148,13 @@ msgstr "Sprache auswählen"
#, elixir-autogen, elixir-format
msgid "Register"
msgstr "Registrieren"
#: lib/mv_web/live/auth/sign_out_live.ex
#, elixir-autogen, elixir-format
msgid "Are you sure you want to sign out?"
msgstr "Möchtest du dich wirklich abmelden?"
#: lib/mv_web/live/auth/sign_out_live.ex
#, elixir-autogen, elixir-format
msgid "Sign out"
msgstr "Abmelden"

View file

@ -145,3 +145,13 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "Register"
msgstr ""
#: lib/mv_web/live/auth/sign_out_live.ex
#, elixir-autogen, elixir-format
msgid "Are you sure you want to sign out?"
msgstr ""
#: lib/mv_web/live/auth/sign_out_live.ex
#, elixir-autogen, elixir-format
msgid "Sign out"
msgstr ""