defmodule ComfycampWeb.UserLoginLive do
use ComfycampWeb, :live_view
def render(assigns) do
~H"""
<.header class="text-center">
Войти в аккаунт
<:subtitle>
Нет аккаунта?
<.link navigate={~p"/users/register"} class="font-semibold text-brand hover:underline">
Создайте
новый.
<.simple_form for={@form} id="login_form" action={~p"/users/log_in"} phx-update="ignore">
<.input field={@form[:email]} type="email" label="Email" required />
<.input field={@form[:password]} type="password" label="Пароль" required />
<:actions>
<.input field={@form[:remember_me]} type="checkbox" label="Запомнить" />
<.link href={~p"/users/reset_password"} class="text-sm font-semibold">
Забыли пароль?
<:actions>
<.button phx-disable-with="Вхожу..." class="w-full">
Войти →
"""
end
def mount(_params, _session, socket) do
email = Phoenix.Flash.get(socket.assigns.flash, :email)
form = to_form(%{"email" => email}, as: "user")
{:ok, assign(socket, form: form), temporary_assigns: [form: form]}
end
end