code_corps v0.0.1 CodeCorps.Policy View Source
Handles authorization for various API actions performed on objects in the database.
Link to this section Summary
Functions
Determines if the specified user can perform the specified action on the specified resource
Scopes a queryable so it’s only able to return those records the specified user is authorized to view
Link to this section Functions
Link to this function
authorize(user, action, struct, params \\ %{})
View Source
authorize(CodeCorps.User.t(), atom(), struct(), map()) :: {:ok, :authorized} | {:error, :not_authorized}
Determines if the specified user can perform the specified action on the specified resource.
The resource can be a record, when performing an action on an existing record, or it can be a map of parameters, when creating a new record.
Link to this function
scope(arg, current_user)
View Source
scope(module(), CodeCorps.User.t()) :: Ecto.Queryable.t()
Scopes a queryable so it’s only able to return those records the specified user is authorized to view.