OIDC-only sign-in, Vereinfacht connection test, locale defaults, and settings/docs cleanup #445
4 changed files with 33 additions and 51 deletions
|
|
@ -370,36 +370,23 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sign-in: hide SSO button and "or" divider when OIDC is not configured.
|
/* Sign-in: hide SSO button and "or" divider when OIDC is not configured.
|
||||||
Use .divider (DaisyUI HorizontalRule) because LiveView does not set id on component root. */
|
Scoped to #sign-in-page to avoid hiding unrelated elements. */
|
||||||
[data-oidc-configured="false"] [id*="oidc"] {
|
#sign-in-page[data-oidc-configured="false"] [id*="oidc"] {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
[data-oidc-configured="false"] a[href*="oidc"] {
|
#sign-in-page[data-oidc-configured="false"] a[href*="oidc"] {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
[data-oidc-configured="false"] .divider {
|
#sign-in-page[data-oidc-configured="false"] .divider {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sign-in: when OIDC-only mode is on, hide password form and "or" divider (show only SSO). */
|
/* Sign-in: when OIDC-only mode is on, hide password form and "or" divider (show only SSO). */
|
||||||
[data-oidc-configured="true"][data-oidc-only="true"] [id*="password"] {
|
#sign-in-page[data-oidc-configured="true"][data-oidc-only="true"] [id*="password"] {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
[data-oidc-configured="true"][data-oidc-only="true"] .divider {
|
#sign-in-page[data-oidc-configured="true"][data-oidc-only="true"] .divider {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sign-in: show "oder" instead of "or" when locale is German (override is compile-time only).
|
|
||||||
Target div.contents so ::after has a box (span may have display:contents). */
|
|
||||||
[data-locale="de"] .divider div.contents {
|
|
||||||
display: block !important;
|
|
||||||
}
|
|
||||||
[data-locale="de"] .divider div.contents > span {
|
|
||||||
font-size: 0;
|
|
||||||
}
|
|
||||||
[data-locale="de"] .divider div.contents::after {
|
|
||||||
content: "oder";
|
|
||||||
font-size: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This file is for your main application CSS */
|
/* This file is for your main application CSS */
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,10 @@ defmodule MvWeb.SignInLive do
|
||||||
session
|
session
|
||||||
|> Map.get("overrides", [AshAuthentication.Phoenix.Overrides.Default])
|
|> Map.get("overrides", [AshAuthentication.Phoenix.Overrides.Default])
|
||||||
|
|
||||||
# Locale from session (set by set_locale plug / LiveUserAuth); default "de"
|
# Locale: same fallback as LiveUserAuth so config :default_locale (e.g. "en" in test) is respected
|
||||||
locale = session["locale"] || "de"
|
locale =
|
||||||
|
session["locale"] || Application.get_env(:mv, :default_locale, "de")
|
||||||
|
|
||||||
Gettext.put_locale(MvWeb.Gettext, locale)
|
Gettext.put_locale(MvWeb.Gettext, locale)
|
||||||
|
|
||||||
socket =
|
socket =
|
||||||
|
|
@ -53,12 +55,13 @@ defmodule MvWeb.SignInLive do
|
||||||
def render(assigns) do
|
def render(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
<div
|
<div
|
||||||
|
id="sign-in-page"
|
||||||
class={@root_class}
|
class={@root_class}
|
||||||
data-oidc-configured={to_string(@oidc_configured)}
|
data-oidc-configured={to_string(@oidc_configured)}
|
||||||
data-oidc-only={to_string(@oidc_only)}
|
data-oidc-only={to_string(@oidc_only)}
|
||||||
data-locale={@locale}
|
data-locale={@locale}
|
||||||
>
|
>
|
||||||
<%!-- Language selector: use @locale from socket (set by LiveUserAuth) so selection matches actual locale --%>
|
<%!-- Language selector --%>
|
||||||
<nav
|
<nav
|
||||||
aria-label={dgettext("auth", "Language selection")}
|
aria-label={dgettext("auth", "Language selection")}
|
||||||
class="absolute top-4 right-4 flex justify-end z-10"
|
class="absolute top-4 right-4 flex justify-end z-10"
|
||||||
|
|
@ -77,28 +80,21 @@ defmodule MvWeb.SignInLive do
|
||||||
</form>
|
</form>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div
|
<.live_component
|
||||||
class={@root_class}
|
module={Components.SignIn}
|
||||||
data-oidc-configured={to_string(@oidc_configured)}
|
otp_app={@otp_app}
|
||||||
data-oidc-only={to_string(@oidc_only)}
|
live_action={@live_action}
|
||||||
data-locale={@locale}
|
path={@path}
|
||||||
>
|
auth_routes_prefix={@auth_routes_prefix}
|
||||||
<.live_component
|
resources={@resources}
|
||||||
module={Components.SignIn}
|
reset_path={@reset_path}
|
||||||
otp_app={@otp_app}
|
register_path={@register_path}
|
||||||
live_action={@live_action}
|
id={@sign_in_id}
|
||||||
path={@path}
|
overrides={@overrides}
|
||||||
auth_routes_prefix={@auth_routes_prefix}
|
current_tenant={@current_tenant}
|
||||||
resources={@resources}
|
context={@context}
|
||||||
reset_path={@reset_path}
|
gettext_fn={@gettext_fn}
|
||||||
register_path={@register_path}
|
/>
|
||||||
id={@sign_in_id}
|
|
||||||
overrides={@overrides}
|
|
||||||
current_tenant={@current_tenant}
|
|
||||||
context={@context}
|
|
||||||
gettext_fn={@gettext_fn}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ defmodule MvWeb.GlobalSettingsLive do
|
||||||
def mount(_params, session, socket) do
|
def mount(_params, session, socket) do
|
||||||
{:ok, settings} = Membership.get_settings()
|
{:ok, settings} = Membership.get_settings()
|
||||||
|
|
||||||
# Get locale from session for translations
|
# Get locale from session; same fallback as router/LiveUserAuth (respects config :default_locale in test)
|
||||||
locale = session["locale"] || "de"
|
locale = session["locale"] || Application.get_env(:mv, :default_locale, "de")
|
||||||
Gettext.put_locale(MvWeb.Gettext, locale)
|
Gettext.put_locale(MvWeb.Gettext, locale)
|
||||||
|
|
||||||
socket =
|
socket =
|
||||||
|
|
@ -407,6 +407,7 @@ defmodule MvWeb.GlobalSettingsLive do
|
||||||
|> assign(:settings, fresh_settings)
|
|> assign(:settings, fresh_settings)
|
||||||
|> assign(:vereinfacht_api_key_set, present?(fresh_settings.vereinfacht_api_key))
|
|> assign(:vereinfacht_api_key_set, present?(fresh_settings.vereinfacht_api_key))
|
||||||
|> assign(:oidc_client_secret_set, present?(fresh_settings.oidc_client_secret))
|
|> assign(:oidc_client_secret_set, present?(fresh_settings.oidc_client_secret))
|
||||||
|
|> assign(:oidc_configured, Mv.Config.oidc_configured?())
|
||||||
|> assign(:vereinfacht_test_result, test_result)
|
|> assign(:vereinfacht_test_result, test_result)
|
||||||
|> put_flash(:info, gettext("Settings updated successfully"))
|
|> put_flash(:info, gettext("Settings updated successfully"))
|
||||||
|> assign_form()
|
|> assign_form()
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ defmodule MvWeb.AuthControllerTest do
|
||||||
# Create unauthenticated conn for this test
|
# Create unauthenticated conn for this test
|
||||||
conn = build_unauthenticated_conn(authenticated_conn)
|
conn = build_unauthenticated_conn(authenticated_conn)
|
||||||
conn = get(conn, ~p"/sign-in")
|
conn = get(conn, ~p"/sign-in")
|
||||||
assert html_response(conn, 200) =~ "Sign in" or html_response(conn, 200) =~ "Anmelden"
|
assert html_response(conn, 200) =~ "Sign in"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "GET /sign-out redirects to home", %{conn: authenticated_conn} do
|
test "GET /sign-out redirects to home", %{conn: authenticated_conn} do
|
||||||
|
|
@ -82,8 +82,7 @@ defmodule MvWeb.AuthControllerTest do
|
||||||
)
|
)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
|
|
||||||
assert html =~ "Email or password was incorrect" or
|
assert html =~ "Email or password was incorrect"
|
||||||
html =~ "Email oder Passwort nicht korrekt"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "password user with non-existent email shows error via LiveView", %{
|
test "password user with non-existent email shows error via LiveView", %{
|
||||||
|
|
@ -101,8 +100,7 @@ defmodule MvWeb.AuthControllerTest do
|
||||||
)
|
)
|
||||||
|> render_submit()
|
|> render_submit()
|
||||||
|
|
||||||
assert html =~ "Email or password was incorrect" or
|
assert html =~ "Email or password was incorrect"
|
||||||
html =~ "Email oder Passwort nicht korrekt"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Registration (LiveView)
|
# Registration (LiveView)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue