HubIdentityElixir.Authentication (HubIdentityElixir v0.1.5) View Source

The Authentication plug for use with restricted routes. Would like to attribute much of this code to the phx_gen_auth package. https://github.com/aaronrenner/phx_gen_auth Thank you.

Link to this section Summary

Functions

Helper method to store the current_user in conn.assigns for easy use in views etc.

Helper method to log in a user. This will store a user into the assign, as well as session under :current_user. Will redirect to "/"

Logs the user out.

Used for routes that require the user to be authenticated.

Link to this section Functions

Link to this function

fetch_current_user(conn, opts)

View Source

Helper method to store the current_user in conn.assigns for easy use in views etc.

Link to this function

login_user(conn, current_user)

View Source

Helper method to log in a user. This will store a user into the assign, as well as session under :current_user. Will redirect to "/"

Logs the user out.

It clears all session data for safety. See renew_session.

Link to this function

require_authenticated_user(conn, opts)

View Source

Used for routes that require the user to be authenticated.

If you want to enforce the user email is confirmed before they use the application at all, here would be a good place.