graphql-devise / graphql_devise

GraphQL interface on top devise_token_auth
MIT License
199 stars 42 forks source link

Set context[:current_resource] upon login #193

Closed TomasBarry closed 3 years ago

TomasBarry commented 3 years ago

If using Object Authorization that relies on context[:current_resource] it is not possible to query for data on the authenticatable object since context[:current_user] is nil after logging in since this is set at the controller level.

This commit fixes this by setting context[:current_resource] to resource if context[:current_resource] is nil (as the implementation may override this already).

GitHub issue - https://github.com/graphql-devise/graphql_devise/issues/192

TomasBarry commented 3 years ago

@mcelicalderon, how would you like this to be tested, or is this sufficient?

Edit: test failures are confusing me a bit. Any idea what it may be?

mcelicalderon commented 3 years ago

Thank you, @TomasBarry! I can think of a way of testing that right now, but we can take care of that afterwards as existing tests didn't break. Apparently dta finally stopped supporting ruby 2.2 and that's why one of tests failed. As that's one of our main dependencies, we will drop support too. I'll fix that before merging your PR, so máster doesn't fail.