feat: migrate all remaining authentication and session flash messages to gettext
Completes the flash message migration by converting all remaining user-facing strings: **UserAuth.ex changes:** - All Plug functions: require_sudo_mode, require_authenticated_user, require_superuser - load_current_organization error messages (3 messages) - All LiveView on_mount callbacks (8 auth-related messages) - Policy consent success message **SessionManager.ex changes:** - Mobile device session management (2 messages) - Alert preferences updates (3 messages including conditional) All messages now use t_auth() for consistent translation in the auth domain. All tests passing (100 tests).
This commit is contained in:
parent
005235a54a
commit
0d85e85884
3 changed files with 86 additions and 5 deletions
|
|
@ -2,6 +2,9 @@ defmodule ToweropsWeb.UserSettingsLive.SessionManager do
|
|||
@moduledoc """
|
||||
Handles browser session and mobile device session management.
|
||||
"""
|
||||
use Gettext, backend: ToweropsWeb.Gettext
|
||||
|
||||
import ToweropsWeb.GettextHelpers
|
||||
|
||||
alias Towerops.Accounts
|
||||
alias Towerops.MobileSessions
|
||||
|
|
@ -13,11 +16,11 @@ defmodule ToweropsWeb.UserSettingsLive.SessionManager do
|
|||
case MobileSessions.revoke_session(session_id) do
|
||||
{:ok, _} ->
|
||||
socket
|
||||
|> Phoenix.LiveView.put_flash(:info, "Mobile device removed successfully.")
|
||||
|> Phoenix.LiveView.put_flash(:info, t_auth("Mobile device removed successfully."))
|
||||
|> assign_mobile_sessions()
|
||||
|
||||
{:error, _} ->
|
||||
Phoenix.LiveView.put_flash(socket, :error, "Failed to remove mobile device.")
|
||||
Phoenix.LiveView.put_flash(socket, :error, t_auth("Failed to remove mobile device."))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -29,14 +32,14 @@ defmodule ToweropsWeb.UserSettingsLive.SessionManager do
|
|||
|
||||
case MobileSessions.update_alert_preferences(session_id, %{alerts_enabled: enabled_bool}) do
|
||||
{:ok, _} ->
|
||||
message = if enabled_bool, do: "Alerts enabled for device", else: "Alerts disabled for device"
|
||||
message = if enabled_bool, do: t_auth("Alerts enabled for device"), else: t_auth("Alerts disabled for device")
|
||||
|
||||
socket
|
||||
|> Phoenix.LiveView.put_flash(:info, message)
|
||||
|> assign_mobile_sessions()
|
||||
|
||||
{:error, _} ->
|
||||
Phoenix.LiveView.put_flash(socket, :error, "Failed to update alert preferences.")
|
||||
Phoenix.LiveView.put_flash(socket, :error, t_auth("Failed to update alert preferences."))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -656,7 +656,7 @@ defmodule ToweropsWeb.UserAuth do
|
|||
socket =
|
||||
socket
|
||||
|> Phoenix.Component.assign(:policies_needing_consent, [])
|
||||
|> LiveView.put_flash(:info, "Thank you for accepting the updated policies.")
|
||||
|> LiveView.put_flash(:info, t_auth("Thank you for accepting the updated policies."))
|
||||
|
||||
{:halt, socket}
|
||||
|
||||
|
|
|
|||
|
|
@ -212,3 +212,81 @@ msgstr ""
|
|||
#, elixir-autogen, elixir-format
|
||||
msgid "✓ Real-time alerts and notifications"
|
||||
msgstr ""
|
||||
|
||||
#: lib/towerops_web/live/user_settings_live/session_manager.ex:35
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Alerts disabled for device"
|
||||
msgstr ""
|
||||
|
||||
#: lib/towerops_web/live/user_settings_live/session_manager.ex:35
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Alerts enabled for device"
|
||||
msgstr ""
|
||||
|
||||
#: lib/towerops_web/live/user_settings_live/session_manager.ex:23
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Failed to remove mobile device."
|
||||
msgstr ""
|
||||
|
||||
#: lib/towerops_web/live/user_settings_live/session_manager.ex:42
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Failed to update alert preferences."
|
||||
msgstr ""
|
||||
|
||||
#: lib/towerops_web/live/user_settings_live/session_manager.ex:19
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Mobile device removed successfully."
|
||||
msgstr ""
|
||||
|
||||
#: lib/towerops_web/user_auth.ex:440
|
||||
#: lib/towerops_web/user_auth.ex:447
|
||||
#: lib/towerops_web/user_auth.ex:512
|
||||
#: lib/towerops_web/user_auth.ex:521
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Organization not found."
|
||||
msgstr ""
|
||||
|
||||
#: lib/towerops_web/user_auth.ex:292
|
||||
#: lib/towerops_web/user_auth.ex:571
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Please verify your identity to continue."
|
||||
msgstr ""
|
||||
|
||||
#: lib/towerops_web/user_auth.ex:659
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Thank you for accepting the updated policies."
|
||||
msgstr ""
|
||||
|
||||
#: lib/towerops_web/user_auth.ex:299
|
||||
#: lib/towerops_web/user_auth.ex:579
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Two-factor authentication is required for this action."
|
||||
msgstr ""
|
||||
|
||||
#: lib/towerops_web/user_auth.ex:434
|
||||
#: lib/towerops_web/user_auth.ex:504
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "You don't have access to this organization."
|
||||
msgstr ""
|
||||
|
||||
#: lib/towerops_web/user_auth.ex:365
|
||||
#: lib/towerops_web/user_auth.ex:550
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "You must be a superuser to access this page."
|
||||
msgstr ""
|
||||
|
||||
#: lib/towerops_web/user_auth.ex:618
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "You must be an organization owner to access this page."
|
||||
msgstr ""
|
||||
|
||||
#: lib/towerops_web/user_auth.ex:348
|
||||
#: lib/towerops_web/user_auth.ex:482
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "You must log in to access this page."
|
||||
msgstr ""
|
||||
|
||||
#: lib/towerops_web/user_auth.ex:600
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "You must set up two-factor authentication to continue."
|
||||
msgstr ""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue