Packages

Addict allows you to manage users on your Phoenix app easily. Register, login, logout, recover password and password updating is available off-the-shelf.

Current section

Files

Jump to
addict lib addict interactors verify_password.ex
Raw

lib/addict/interactors/verify_password.ex

defmodule Addict.Interactors.VerifyPassword do
@doc """
Verifies if the password for the user is valid
Returns `{:ok}` or `{:error, [authentication: "Incorrect e-mail/password"]}`
"""
def call(user, password) do
Comeonin.Pbkdf2.checkpw(password, user.encrypted_password) |> process_response
end
defp process_response(false) do
{:error, [authentication: "Incorrect e-mail/password"]}
end
defp process_response(true) do
{:ok}
end
end