Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

User is getting passed to the policy as nil. #58

@jejacks0n

Description

@jejacks0n

This is true in released gem and master, the reason seems to be around this line:

https://github.com/ontohub/graphql-pundit/blob/master/lib/graphql-pundit/authorization.rb#L58

We don't see self.class.current_user being set to anything by default, and so I'm guessing the tests might set it but it isn't being defaulted in actual code.

I've worked around this by reopening the class and defining a current_user class method e.g. monkeypatching. note that I'm using rails and so can chain the namespace.

class GraphQL::Pundit::Field
  def self.current_user
    :current_user
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions