Phauxth v2.0.0-rc.1 Phauxth.Login.Base View Source
Base module for handling login.
This is used by Phauxth.Login and can also be used to create custom login modules.
Custom login modules
One example of a custom login module is shown below:
defmodule MyApp.LoginConfirm do
use Phauxth.Login.Base
def authenticate(%{"password" => password} = params, opts) do
case Config.user_context().get_by(params) do
nil -> {:error, "no user found"}
%{confirmed_at: nil} -> {:error, "account unconfirmed"}
user -> Config.crypto_module().check_pass(user, password, opts)
end
end
end
In this example, the authenticate
function is overridden to check
the user struct to see if the user is confirmed. If the user has not
been confirmed, an error is returned.