Login por matricula

This commit is contained in:
2024-07-01 12:19:08 -03:00
parent 10b1f8c855
commit b11499ff2d
6 changed files with 32 additions and 34 deletions

View File

@ -19,9 +19,9 @@ defmodule DerivantesWeb.UserSessionController do
end
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
|> put_flash(:info, info)
|> 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.
conn
|> 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")
end
end