aprs.me/lib/aprs_web/live/user_login_live.ex
2025-06-22 09:38:05 -05:00

53 lines
1.6 KiB
Elixir

defmodule AprsWeb.UserLoginLive do
@moduledoc false
use AprsWeb, :live_view
alias Aprs.Accounts
alias Aprs.Accounts.User
def render(assigns) do
~H"""
<div class="mx-auto max-w-sm">
<.header class="text-center" />
<h2 class="text-center text-2xl font-bold mt-6 mb-2">Sign in to account</h2>
<p class="text-center text-gray-600 mb-6">
Don't have an account?
<.link navigate={~p"/users/register"} class="font-semibold text-brand hover:underline">
Sign up
</.link>
for an account now.
</p>
<.simple_form
:let={f}
id="login_form"
for={@changeset}
action={~p"/users/log_in"}
as={:user}
phx-update="ignore"
>
<.input field={{f, :email}} type="email" label="Email" required />
<.input field={{f, :password}} type="password" label="Password" required />
<:actions :let={f}>
<.input field={{f, :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="Signing in..." class="w-full">
Sign in <span aria-hidden="true">→</span>
</.button>
</:actions>
</.simple_form>
</div>
"""
end
def mount(_params, _session, socket) do
changeset = Accounts.change_user_registration(%User{})
{:ok, assign(socket, changeset: changeset), temporary_assigns: [changeset: nil]}
end
end