Code review: SignInLive locale fallback, single root + id, CSS scoped to #sign-in-page, remove or-hack, refresh oidc_configured after save, tests assert English only

This commit is contained in:
Moritz 2026-02-24 15:41:30 +01:00
parent 951d01dc4d
commit fae1804fb1
Signed by: moritz
GPG key ID: 1020A035E5DD0824
4 changed files with 33 additions and 51 deletions

View file

@ -18,8 +18,10 @@ defmodule MvWeb.SignInLive do
session
|> Map.get("overrides", [AshAuthentication.Phoenix.Overrides.Default])
# Locale from session (set by set_locale plug / LiveUserAuth); default "de"
locale = session["locale"] || "de"
# Locale: same fallback as LiveUserAuth so config :default_locale (e.g. "en" in test) is respected
locale =
session["locale"] || Application.get_env(:mv, :default_locale, "de")
Gettext.put_locale(MvWeb.Gettext, locale)
socket =
@ -53,12 +55,13 @@ defmodule MvWeb.SignInLive do
def render(assigns) do
~H"""
<div
id="sign-in-page"
class={@root_class}
data-oidc-configured={to_string(@oidc_configured)}
data-oidc-only={to_string(@oidc_only)}
data-locale={@locale}
>
<%!-- Language selector: use @locale from socket (set by LiveUserAuth) so selection matches actual locale --%>
<%!-- Language selector --%>
<nav
aria-label={dgettext("auth", "Language selection")}
class="absolute top-4 right-4 flex justify-end z-10"
@ -77,28 +80,21 @@ defmodule MvWeb.SignInLive do
</form>
</nav>
<div
class={@root_class}
data-oidc-configured={to_string(@oidc_configured)}
data-oidc-only={to_string(@oidc_only)}
data-locale={@locale}
>
<.live_component
module={Components.SignIn}
otp_app={@otp_app}
live_action={@live_action}
path={@path}
auth_routes_prefix={@auth_routes_prefix}
resources={@resources}
reset_path={@reset_path}
register_path={@register_path}
id={@sign_in_id}
overrides={@overrides}
current_tenant={@current_tenant}
context={@context}
gettext_fn={@gettext_fn}
/>
</div>
<.live_component
module={Components.SignIn}
otp_app={@otp_app}
live_action={@live_action}
path={@path}
auth_routes_prefix={@auth_routes_prefix}
resources={@resources}
reset_path={@reset_path}
register_path={@register_path}
id={@sign_in_id}
overrides={@overrides}
current_tenant={@current_tenant}
context={@context}
gettext_fn={@gettext_fn}
/>
</div>
"""
end