2024-07-11 01:14:16 +05:00
|
|
|
|
defmodule ComfycampWeb.UserConfirmationInstructionsLive do
|
|
|
|
|
use ComfycampWeb, :live_view
|
|
|
|
|
|
|
|
|
|
alias Comfycamp.Accounts
|
|
|
|
|
|
|
|
|
|
def render(assigns) do
|
|
|
|
|
~H"""
|
|
|
|
|
<div class="mx-auto max-w-sm">
|
|
|
|
|
<.header class="text-center">
|
2024-07-22 21:12:29 +05:00
|
|
|
|
Не получили инструкцию для подтверждения?
|
|
|
|
|
<:subtitle>Мы отправим новую ссылку на вашу почту.</:subtitle>
|
2024-07-11 01:14:16 +05:00
|
|
|
|
</.header>
|
|
|
|
|
|
|
|
|
|
<.simple_form for={@form} id="resend_confirmation_form" phx-submit="send_instructions">
|
|
|
|
|
<.input field={@form[:email]} type="email" placeholder="Email" required />
|
|
|
|
|
<:actions>
|
2024-07-22 21:12:29 +05:00
|
|
|
|
<.button phx-disable-with="Отправляю..." class="w-full">
|
|
|
|
|
Отправить инструкции повторно
|
2024-07-11 01:14:16 +05:00
|
|
|
|
</.button>
|
|
|
|
|
</:actions>
|
|
|
|
|
</.simple_form>
|
|
|
|
|
|
|
|
|
|
<p class="text-center mt-4">
|
2024-07-22 21:12:29 +05:00
|
|
|
|
<.link href={~p"/users/register"}>Зарегистрироваться</.link>
|
|
|
|
|
| <.link href={~p"/users/log_in"}>Войти</.link>
|
2024-07-11 01:14:16 +05:00
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
"""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def mount(_params, _session, socket) do
|
|
|
|
|
{:ok, assign(socket, form: to_form(%{}, as: "user"))}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def handle_event("send_instructions", %{"user" => %{"email" => email}}, socket) do
|
|
|
|
|
if user = Accounts.get_user_by_email(email) do
|
|
|
|
|
Accounts.deliver_user_confirmation_instructions(
|
|
|
|
|
user,
|
|
|
|
|
&url(~p"/users/confirm/#{&1}")
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
info =
|
|
|
|
|
"If your email is in our system and it has not been confirmed yet, you will receive an email with instructions shortly."
|
|
|
|
|
|
|
|
|
|
{:noreply,
|
|
|
|
|
socket
|
|
|
|
|
|> put_flash(:info, info)
|
|
|
|
|
|> redirect(to: ~p"/")}
|
|
|
|
|
end
|
|
|
|
|
end
|