Last active
December 11, 2020 18:36
-
-
Save stephanos/3efc2d54122d28928c05b06f60929fdf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Auth do | |
def login(email, password) do | |
case UserRepo.find_by_email(email) do | |
{:ok, user} -> | |
password_hash = BCrypt.hash(password) | |
cond do | |
user.hash != hash -> :error | |
user.active == false -> :error | |
user.deleted_at != nil -> :error | |
true -> | |
UserRepo.update_last_login_date(user, DateTime.utc_now()) | |
{:ok, user} | |
end | |
_ -> :error | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment