Skip to content

Commit

Permalink
Merge pull request cpjk#63 from cpjk/privatize_function
Browse files Browse the repository at this point in the history
Privatize do_authorize_controller/2
  • Loading branch information
cpjk authored Jun 14, 2017
2 parents a415916 + 9d97858 commit fabbc0d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/canary/plugs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ defmodule Canary.Plugs do
authorize_controller checks for the name of the current controller in one of the following places
1) :phoenix_controller in conn.private
2) :canary_controller in conn.assigns
In case you are not using phoenix, make sure you set the controller name in the conn.assigns
Note that in case neither of :phoenix_controller or :canary_controller are found the requested
authorization won't necessarily fail, rather it will trigger a can? function with user assinged as nil
Note that in case neither of `:phoenix_controller` or `:canary_controller` are found the requested
authorization won't necessarily fail, rather it will trigger a `.can?` function with a `nil` controller
If authorization succeeds, sets `conn.assigns.authorized` to true.
Expand Down Expand Up @@ -159,7 +160,7 @@ defmodule Canary.Plugs do
end
end

def do_authorize_controller(conn, opts) do
defp do_authorize_controller(conn, opts) do
controller = conn.assigns[:canary_controller] || conn.private[:phoenix_controller]
current_user_name = opts[:current_user] ||
Application.get_env(:canary, :current_user, :current_user)
Expand Down

0 comments on commit fabbc0d

Please sign in to comment.