Alkemist v1.0.1-rc Alkemist.Authorization
A fallback Authentication and authorization provider. Use this file as a template to implement your own authentication methods.
Then in your config.exs specify the Authorization Provider:
config :alkemist, Alkemist,
authorization_provider: MyApp.Authorization
Link to this section Summary
Functions
Authorizes a controller action for a resource
Returns the current user. When you implement this action, you can return your currently logged in user from the conn.assigns
Returns the display name for the current user from the conn
Link to this section Functions
Authorizes a controller action for a resource.
Usage:
iex> Alkemist.Authorization.authorize_action(Alkemist.Post, conn, :delete) true
iex> Alkemist.Authorization.authorize_action(%Alkemist.Post{user_id: 1}, conn, :update) true
Returns the current user. When you implement this action, you can return your currently logged in user from the conn.assigns
Example:
def current_user(conn), do: conn.assigns.current_user
Returns the display name for the current user from the conn
Example:
def current_user_name(_conn), do: current_user(conn).username