comfycamp/lib/comfycamp_web/live/user_login_live.ex

44 lines
1.4 KiB
Elixir
Raw Normal View History

2024-07-11 01:14:16 +05:00
defmodule ComfycampWeb.UserLoginLive do
use ComfycampWeb, :live_view
def render(assigns) do
~H"""
<div class="mx-auto max-w-sm">
<.header class="text-center">
Войти в аккаунт
2024-07-11 01:14:16 +05:00
<:subtitle>
Нет аккаунта?
2024-07-11 01:14:16 +05:00
<.link navigate={~p"/users/register"} class="font-semibold text-brand hover:underline">
Создайте
2024-07-11 01:14:16 +05:00
</.link>
новый.
2024-07-11 01:14:16 +05:00
</:subtitle>
</.header>
<.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 />
2024-07-11 01:14:16 +05:00
<:actions>
<.input field={@form[:remember_me]} type="checkbox" label="Запомнить" />
2024-07-11 01:14:16 +05:00
<.link href={~p"/users/reset_password"} class="text-sm font-semibold">
Забыли пароль?
2024-07-11 01:14:16 +05:00
</.link>
</:actions>
<:actions>
<.button phx-disable-with="Вхожу..." class="w-full">
Войти <span aria-hidden="true"></span>
2024-07-11 01:14:16 +05:00
</.button>
</:actions>
</.simple_form>
</div>
"""
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