0

I'm trying to use clearance with doorkeeper and from the doorkeeper documentation, I have to access the User object like so:

resource_owner_authenticator do
  @user = env[:clearance].current_user

  unless @user
    session[:return_to] = request.fullpath
    redirect_to(sign_in_url)
  end

  @user
end

https://github.com/doorkeeper-gem/doorkeeper/wiki/Authenticating-using-Clearance-or-DIY

but where do I get the env variable from? Also, I have tried to find the user in session[:current_user] and session[:user] but it's not there.

Thanks

  • `env` is the `Rack.env` hash. Its not a local variable - its a utility method to access `ENV`. https://stackoverflow.com/questions/17396611/what-is-the-env-variable-in-rack-middleware – max Aug 11 '17 at 20:15
  • Hi max, thanks for your reply. I know that env is the Rack.env but how do I access it? Substituting env with Rack.env in the code above gives me gives me undefined method `env' for Rack:Module. – user2346012 Aug 14 '17 at 14:53
  • By the constant ENV. Or by the method `self.env` in a controller. – max Aug 15 '17 at 00:55

0 Answers0