Login por matricula
This commit is contained in:
parent
10b1f8c855
commit
b11499ff2d
@ -58,10 +58,12 @@ body{
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
height: max-content;
|
height: max-content;
|
||||||
width: 250px;
|
width: 300px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div > .reg_form{}
|
||||||
|
|
||||||
.auth_form img{
|
.auth_form img{
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
@ -83,6 +85,10 @@ body{
|
|||||||
background-color: #5bc0de;
|
background-color: #5bc0de;
|
||||||
color: white;
|
color: white;
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
|
.imput_text{
|
||||||
|
margin-top: 5px;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
padding-bottom: 10px;
|
padding-bottom: 10px;
|
||||||
width: 205px;
|
width: 205px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
|
@ -44,6 +44,12 @@ defmodule Derivantes.Accounts do
|
|||||||
if User.valid_password?(user, password), do: user
|
if User.valid_password?(user, password), do: user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_user_by_matricula_and_password(matricula, password)
|
||||||
|
when is_binary(matricula) and is_binary(password) do
|
||||||
|
user = Repo.get_by(User, matricula: matricula)
|
||||||
|
if User.valid_password?(user, password), do: user
|
||||||
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Gets a single user.
|
Gets a single user.
|
||||||
|
|
||||||
|
@ -22,19 +22,13 @@ defmodule Derivantes.Accounts.UserNotifier do
|
|||||||
Deliver instructions to confirm account.
|
Deliver instructions to confirm account.
|
||||||
"""
|
"""
|
||||||
def deliver_confirmation_instructions(user, url) do
|
def deliver_confirmation_instructions(user, url) do
|
||||||
deliver(user.email, "Confirmation instructions", """
|
deliver(user.email, "Confirme su correo electrónico", """
|
||||||
|
|
||||||
==============================
|
Hola #{user.email},
|
||||||
|
Active su cuenta haciendo click en el siguiente enlace:
|
||||||
Hi #{user.email},
|
|
||||||
|
|
||||||
You can confirm your account by visiting the URL below:
|
|
||||||
|
|
||||||
#{url}
|
#{url}
|
||||||
|
|
||||||
If you didn't create an account with us, please ignore this.
|
|
||||||
|
|
||||||
==============================
|
|
||||||
""")
|
""")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -13,43 +13,35 @@
|
|||||||
<script src="https://kit.fontawesome.com/8afa33c96d.js" crossorigin="anonymous"></script>
|
<script src="https://kit.fontawesome.com/8afa33c96d.js" crossorigin="anonymous"></script>
|
||||||
</head>
|
</head>
|
||||||
<body class="gray antialiased">
|
<body class="gray antialiased">
|
||||||
<ul class="relative z-10 flex items-center gap-4 px-4 sm:px-6 lg:px-8 justify-end root_header">
|
<ul class="relative z-10 flex items-center gap-4 px-4 sm:px-6 lg:px-8 justify-end root_header p-3">
|
||||||
<%= if @current_user do %>
|
<%= if @current_user do %>
|
||||||
<li class="text-[0.8125rem] leading-6 text-zinc-900">
|
<li class="text-m leading-6 text-white">
|
||||||
<%= @current_user.email %>
|
<%= @current_user.email %>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<.link
|
|
||||||
href={~p"/derivantes/settings"}
|
|
||||||
class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700"
|
|
||||||
>
|
|
||||||
Settings
|
|
||||||
</.link>
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<.link
|
<.link
|
||||||
href={~p"/derivantes/log_out"}
|
href={~p"/derivantes/log_out"}
|
||||||
method="delete"
|
method="delete"
|
||||||
class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700"
|
class="text-m leading-6 text-white hover:text-gray font-semibold"
|
||||||
>
|
>
|
||||||
Log out
|
Salir
|
||||||
</.link>
|
</.link>
|
||||||
</li>
|
</li>
|
||||||
<% else %>
|
<% else %>
|
||||||
<li>
|
<li>
|
||||||
<.link
|
<.link
|
||||||
href={~p"/derivantes/register"}
|
href={~p"/derivantes/register"}
|
||||||
class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700"
|
class="text-m leading-6 text-white hover:text-gray"
|
||||||
>
|
>
|
||||||
Register
|
Registro
|
||||||
</.link>
|
</.link>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<.link
|
<.link
|
||||||
href={~p"/derivantes/log_in"}
|
href={~p"/derivantes/log_in"}
|
||||||
class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700"
|
class="text-m leading-6 text-white hover:text-gray"
|
||||||
>
|
>
|
||||||
Log in
|
Ingresar
|
||||||
</.link>
|
</.link>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -19,9 +19,9 @@ defmodule DerivantesWeb.UserSessionController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
defp create(conn, %{"user" => user_params}, info) do
|
defp create(conn, %{"user" => user_params}, info) do
|
||||||
%{"email" => email, "password" => password} = user_params
|
%{"matricula" => matricula, "password" => password} = user_params
|
||||||
|
|
||||||
if user = Accounts.get_user_by_email_and_password(email, password) do
|
if user = Accounts.get_user_by_matricula_and_password(matricula, password) do
|
||||||
conn
|
conn
|
||||||
|> put_flash(:info, info)
|
|> put_flash(:info, info)
|
||||||
|> UserAuth.log_in_user(user, user_params)
|
|> UserAuth.log_in_user(user, user_params)
|
||||||
@ -29,7 +29,7 @@ defmodule DerivantesWeb.UserSessionController do
|
|||||||
# In order to prevent user enumeration attacks, don't disclose whether the email is registered.
|
# In order to prevent user enumeration attacks, don't disclose whether the email is registered.
|
||||||
conn
|
conn
|
||||||
|> put_flash(:error, "Invalid email or password")
|
|> put_flash(:error, "Invalid email or password")
|
||||||
|> put_flash(:email, String.slice(email, 0, 160))
|
|> put_flash(:matricula, String.slice(matricula, 0, 160))
|
||||||
|> redirect(to: ~p"/derivantes/log_in")
|
|> redirect(to: ~p"/derivantes/log_in")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -14,11 +14,11 @@ defmodule DerivantesWeb.UserLoginLive do
|
|||||||
>
|
>
|
||||||
<img src={~p"/images/sana_americano_logo.png"} alt="Sanatorio Americano Logo"/>
|
<img src={~p"/images/sana_americano_logo.png"} alt="Sanatorio Americano Logo"/>
|
||||||
<.input
|
<.input
|
||||||
field={@form[:email]}
|
field={@form[:matricula]}
|
||||||
type="email"
|
type="number"
|
||||||
label=""
|
label=""
|
||||||
class="imput_text"
|
class="imput_text"
|
||||||
placeholder="Email"
|
placeholder="Matrícula"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<.input
|
<.input
|
||||||
@ -66,8 +66,8 @@ defmodule DerivantesWeb.UserLoginLive do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def mount(_params, _session, socket) do
|
def mount(_params, _session, socket) do
|
||||||
email = Phoenix.Flash.get(socket.assigns.flash, :email)
|
matricula = Phoenix.Flash.get(socket.assigns.flash, :matricula)
|
||||||
form = to_form(%{"email" => email}, as: "user")
|
form = to_form(%{"matricula" => matricula}, as: "user")
|
||||||
{:ok, assign(socket, form: form), temporary_assigns: [form: form]}
|
{:ok, assign(socket, form: form), temporary_assigns: [form: form]}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user