mirror of
https://github.com/ClaperCo/Claper.git
synced 2025-12-16 20:07:59 +01:00
23 lines
656 B
Elixir
23 lines
656 B
Elixir
|
|
defmodule ClaperWeb.UserLiveAuth do
|
||
|
|
import Phoenix.LiveView
|
||
|
|
alias ClaperWeb.Router.Helpers, as: Routes
|
||
|
|
|
||
|
|
def on_mount(:default, _params, %{"current_user" => current_user} = _session, socket) do
|
||
|
|
if current_user.confirmed_at do
|
||
|
|
socket =
|
||
|
|
socket
|
||
|
|
|> assign_new(:current_user, fn -> current_user end)
|
||
|
|
|
||
|
|
{:cont, socket}
|
||
|
|
else
|
||
|
|
{:halt,
|
||
|
|
redirect(socket,
|
||
|
|
to: Routes.user_registration_path(socket, :confirm, %{email: current_user.email})
|
||
|
|
)}
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
def on_mount(:default, _params, _session, socket),
|
||
|
|
do: {:halt, redirect(socket, to: Routes.user_registration_path(socket, :confirm))}
|
||
|
|
end
|