mirror of
https://github.com/danbee/chess
synced 2025-03-04 08:39:06 +00:00
More idiomatic password hashing
This commit is contained in:
parent
0568b69cbb
commit
19037c723f
@ -23,11 +23,13 @@ defmodule Chess.Auth.User do
|
|||||||
|> hash_password()
|
|> hash_password()
|
||||||
end
|
end
|
||||||
|
|
||||||
defp hash_password(
|
defp hash_password(changeset) do
|
||||||
%Ecto.Changeset{valid?: true, changes: %{password: password}} = changeset
|
password = get_change(changeset, :password)
|
||||||
) do
|
if password do
|
||||||
change(changeset, Argon2.add_hash(password))
|
changeset
|
||||||
|
|> change(Argon2.add_hash(password))
|
||||||
|
else
|
||||||
|
changeset
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp hash_password(changeset), do: changeset
|
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user