chiya/lib/chiya_web/live/user_login_live.ex

44 lines
1.4 KiB
Elixir
Raw Normal View History

2023-03-05 16:13:00 +01:00
defmodule ChiyaWeb.UserLoginLive do
use ChiyaWeb, :live_view
def render(assigns) do
~H"""
<div class="mx-auto max-w-sm">
<.header class="text-center">
Sign in to account
<:subtitle>
Don't have an account?
2023-03-07 21:15:26 +01:00
<.link navigate={~p"/user/register"} class="font-semibold text-brand hover:underline">
2023-03-05 16:13:00 +01:00
Sign up
</.link>
for an account now.
</:subtitle>
</.header>
2023-03-07 21:15:26 +01:00
<.simple_form for={@form} id="login_form" action={~p"/user/log_in"} phx-update="ignore">
2023-03-05 16:13:00 +01:00
<.input field={@form[:email]} type="email" label="Email" required />
<.input field={@form[:password]} type="password" label="Password" required />
<:actions>
<.input field={@form[:remember_me]} type="checkbox" label="Keep me logged in" />
2023-04-10 17:25:47 +02:00
<.link href={~p"/user/reset_password"} class="text-sm font-semibold dark:text-gray-100">
2023-03-05 16:13:00 +01:00
Forgot your password?
</.link>
</:actions>
<:actions>
<.button phx-disable-with="Signing in..." class="w-full">
Sign in <span aria-hidden="true"></span>
</.button>
</:actions>
</.simple_form>
</div>
"""
end
def mount(_params, _session, socket) do
email = live_flash(socket.assigns.flash, :email)
form = to_form(%{"email" => email}, as: "user")
{:ok, assign(socket, form: form), temporary_assigns: [form: form]}
end
end