Doorman v0.1.1 Doorboy
Doorboy main module made with macro.
Link to this section Summary
Functions
Use this module in your Phoenix Controller.
Link to this section Functions
Link to this macro
__using__(list) (macro)
Use this module in your Phoenix Controller.
Example
defmodule SampleController do
use Doorboy, policy: SamplePolicy
def create(conn, params)
book = Book.fetch(params.book_id)
{:ok, _} <- authorize :create, user: conn.current_user, book: book
end
end
Policy file looks like this.
Example
defmodule SamplePolicy do
// If this function returns true, authorize/2 returns {:ok, nil}
// If this function returns false, authorize/2 returns {:error, :unauthorized}
def create(user: user, book: book) do
user && user.id == book.user_id
end
end