zoeys.computer/lib/zoeyscomputer_web/live/user_login_live.ex

50 lines
1.5 KiB
Elixir
Raw Normal View History

2024-10-21 13:57:31 -04:00
defmodule ZoeyscomputerWeb.UserLoginLive do
use ZoeyscomputerWeb, :live_view
def render(assigns) do
~H"""
2024-10-21 19:20:35 -04:00
<div class="mx-auto max-w-sm text-ctp-overlay2">
<.header class="text-center text-ctp-mauve">
2024-10-21 13:57:31 -04:00
Log in to account
<:subtitle>
Don't have an account?
2024-10-21 19:20:35 -04:00
<.link navigate={~p"/users/register"} class="font-semibold text-ctp-mauve hover:underline">
2024-10-21 13:57:31 -04:00
Sign up
</.link>
for an account now.
</:subtitle>
</.header>
2024-10-21 19:20:35 -04:00
<.simple_form
class="bg-ctp-crust"
for={@form}
id="login_form"
action={~p"/users/log_in"}
phx-update="ignore"
>
2024-10-21 13:57:31 -04: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" />
<.link href={~p"/users/reset_password"} class="text-sm font-semibold">
Forgot your password?
</.link>
</:actions>
<:actions>
<.button phx-disable-with="Logging in..." class="w-full">
Log in <span aria-hidden="true"></span>
</.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