doorman v0.6.2 Doorman

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 conns assigns has a non-nil :current_user, otherwise returns false

Link to this section Functions

Link to this function 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.

Doorman.authenticate("joe@dirt.com", "brandyr00lz")

If you want to authenticate other modules, you can pass in the module directly.

Doorman.authenticate(Customer, "brandy@dirt.com", "super-password")
Link to this function 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)
Doorman.authenticate_user(user, "brandyr00lz")
Link to this function logged_in?(conn)

Returns true if passed in conns 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..