berrypod/lib/berrypod_web/live/auth/settings.ex

31 lines
827 B
Elixir
Raw Permalink Normal View History

defmodule BerrypodWeb.Auth.Settings do
use BerrypodWeb, :live_view
2025-12-30 12:26:46 +00:00
alias Berrypod.Accounts
2025-12-30 12:26:46 +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
{:ok, redirect(socket, to: ~p"/admin/settings")}
2025-12-30 12:26:46 +00:00
end
# Main mount: just redirect — account settings live in admin now
2025-12-30 12:26:46 +00:00
def mount(_params, _session, socket) do
{:ok, redirect(socket, to: ~p"/admin/settings")}
2025-12-30 12:26:46 +00:00
end
@impl true
def render(assigns) do
~H""
2025-12-30 12:26:46 +00:00
end
end