I’m following this tutorial on authenticating a user when they log in/out, in phoenix. It requires that I create in my Guardian
implementation module the authenticate
function with different arities, corresponding to different scenarios. This is the part that is failing:
def authenticate(%User{} = user, password) do
authenticate(
user,
password,
Argon2.verify_pass(password, user.encrypted_password)
)
end
defp authenticate(nil, password) do
authenticate(nil, password, Argon2.no_user_verify())
end
defp authenticate(user, _password, true) do
{:ok, user}
end
defp authenticate(_account, _password, false) do
{:error, :invalid_credentials}
end
This fails with the following error:
** (CompileError) lib/myapp_web/authentication.ex:44: defp authenticate/2 already defined as def in lib/myapp_web/authentication.ex:36
lib/myapp_web/authentication.ex:44: (module)
I am using elixir 1.14.1, Erlang 25, with phoenix 1.6, guardian 2.3, ueberauth 0.10.3