cpjk / canary

:hatching_chick: Elixir authorization and resource-loading library for Plug applications.
MIT License
474 stars 51 forks source link

Added loaded resource from model id to conn.assigns #47

Closed qgadrian closed 8 years ago

qgadrian commented 8 years ago

Since might be necessary a loaded resource from the model id, I think it should be added to conn.assigns.

The problem is that, using Guardian, there is already a current_user from the jwt. But you cannot access to the requested resource if you are requesting another user.

cpjk commented 8 years ago

If you use load_and_authorize_resource, the resource will be present already. I'm probably missing something, but what does this solve that load_and_authorize_resource does not?

qgadrian commented 8 years ago

Actually it does not. I misunderstood the load resource method and thought that it would load the session user, mixing concepts between Guardian and Canary. Sorry!

I'll close de PR.

cpjk commented 8 years ago

Glad I could help!

cpjk commented 8 years ago

@qgadrian I updated the README to be less confusing about what resource is being loaded in each case.

qgadrian commented 8 years ago

Now it won't be confusing anymore.

Thank you @cpjk!