2026-02-12 00:16:32 +00:00
|
|
|
defmodule SimpleshopThemeWeb.Auth.Settings do
|
2025-12-30 12:26:46 +00:00
|
|
|
use SimpleshopThemeWeb, :live_view
|
|
|
|
|
|
|
|
|
|
alias SimpleshopTheme.Accounts
|
|
|
|
|
|
2026-02-12 09:04:51 +00:00
|
|
|
# Confirm-email token: process it and redirect to admin settings
|
2025-12-30 12:26:46 +00:00
|
|
|
@impl true
|
|
|
|
|
def mount(%{"token" => token}, _session, socket) do
|
|
|
|
|
socket =
|
|
|
|
|
case Accounts.update_user_email(socket.assigns.current_scope.user, token) do
|
|
|
|
|
{:ok, _user} ->
|
|
|
|
|
put_flash(socket, :info, "Email changed successfully.")
|
|
|
|
|
|
|
|
|
|
{:error, _} ->
|
|
|
|
|
put_flash(socket, :error, "Email change link is invalid or it has expired.")
|
|
|
|
|
end
|
|
|
|
|
|
2026-02-12 09:04:51 +00:00
|
|
|
{:ok, redirect(socket, to: ~p"/admin/settings")}
|
2025-12-30 12:26:46 +00:00
|
|
|
end
|
|
|
|
|
|
2026-02-12 09:04:51 +00:00
|
|
|
# Main mount: just redirect — account settings live in admin now
|
2025-12-30 12:26:46 +00:00
|
|
|
def mount(_params, _session, socket) do
|
2026-02-12 09:04:51 +00:00
|
|
|
{:ok, redirect(socket, to: ~p"/admin/settings")}
|
2025-12-30 12:26:46 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@impl true
|
2026-02-12 09:04:51 +00:00
|
|
|
def render(assigns) do
|
|
|
|
|
~H""
|
2025-12-30 12:26:46 +00:00
|
|
|
end
|
|
|
|
|
end
|