entrance v0.1.0 Entrance
Provides authentication helpers that take advantage of the options configured in your config files.
Link to this section Summary
Functions
Authenticates a user by their email and password. Returns the user if the user is found and the password is correct, otherwise nil.
Authenticates a user. Returns true if the user's password and the given password match based on the strategy configured, otherwise false.
Returns true if passed in conn
s assigns
has a non-nil :current_user
,
otherwise returns false.
Link to this section Functions
authenticate(user_module \\ nil, email, password)
Authenticates a user by their email and password. Returns the user if the user is found and the password is correct, otherwise nil.
Requires user_module
, secure_with
, and repo
to be configured via
Mix.Config
. See [README.md] for an example.
Entrance.authenticate("joe@dirt.com", "brandyr00lz")
If you want to authenticate other modules, you can pass in the module directly.
Entrance.authenticate(Customer, "brandy@dirt.com", "super-password")
authenticate_user(user, password)
Authenticates a user. Returns true if the user's password and the given password match based on the strategy configured, otherwise false.
Use authenticate/2
if if you would to authenticate by email and password.
Requires user_module
, secure_with
, and repo
to be configured via
Mix.Config
. See [README.md] for an example.
user = Myapp.Repo.get(Myapp.User, 1)
Entrance.authenticate_user(user, "brandyr00lz")
logged_in?(conn)
Returns true if passed in conn
s assigns
has a non-nil :current_user
,
otherwise returns false.
Make sure your pipeline uses a login plug to fetch the current user for this function to work correctly..