Gardien v1.0.0 Gardien.View
View authorization functions.
Summary
Functions
Authorize user action on a given resource
Functions
Authorize user action on a given resource.
user is extracted from conn struct based on user configuration
(see configuration section in Gardien module docs).
Returns true when user is authorized and false otherwise.
Example:
# in view
defmodule MyApplication.PostView do
import Gardien.View, only: [authorize?: 3]
end
# in template
<%= if authorize?(post, :delete, @conn) do %>
<%= link "Delete", to: post_path(@conn, :delete, post), method: :delete %>
<% end %>