Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Since Doorkeeper is an isolated Engine we have no access to whatever you did in ApplicationController. But what if you need a current_user? What could be a workaround here?

The first idea is to monkey-patch ActionController::Base. Any better thoughts?

share|improve this question
add comment

2 Answers

Unless there are no answers, may be my own dirty monkey patch will be useful to someone.

in initializers/action_controller_patch.rb:

module ActionController
  Base.class_eval do

    def current_user
      @current_user ||= User.find(session[:user_id]) if session[:user_id]
    end
    helper_method :current_user

  end
end
share|improve this answer
add comment

I think you can find it on this page.

https://github.com/applicake/doorkeeper/wiki/Using-Resource-Owner-Password-Credentials-flow

I am using credential auth pattern, so in my case this works.

Doorkeeper.configure do
  resource_owner_from_credentials do |routes|
    request.params[:user] = {:email => request.params[:username], :password => request.params[:password]}
    request.env["devise.allow_params_authentication"] = true
    request.env["warden"].authenticate!(:scope => :user)
  end
end
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.