freedive/lib/freedive_web/live/user_login_live.ex

55 lines
1.7 KiB
Elixir
Raw Normal View History

2024-05-09 23:08:49 +02:00
defmodule FreediveWeb.UserLoginLive do
use FreediveWeb, :live_view
def render(assigns) do
~H"""
2024-05-13 12:25:37 +02:00
<.hero>
<.container>
<.block>
<.title is-4>
Log in to account
</.title>
<.subtitle is-6 has-text-grey>
freedive@hostname
</.subtitle>
</.block>
2024-05-09 23:08:49 +02:00
2024-05-13 12:25:37 +02:00
<.column is-6-desktop>
<.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="Password" required />
2024-05-09 23:08:49 +02:00
2024-05-13 12:25:37 +02:00
<: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 type="submit" phx-disable-with="Logging in..." is-info>
Log in <span aria-hidden="true"></span>
</.button>
</:actions>
<:actions>
<.block>
Don't have an account?
<.link navigate={~p"/users/register"} class="font-semibold text-brand hover:underline">
2024-05-13 16:24:06 +02:00
Register
2024-05-13 12:25:37 +02:00
</.link>
2024-05-13 16:24:06 +02:00
an account now.
2024-05-13 12:25:37 +02:00
</.block>
</:actions>
</.simple_form>
</.column>
</.container>
</.hero>
2024-05-09 23:08:49 +02:00
"""
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