Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TokensController and TokenInfoController inherit ActionController::Metal #443

Merged
merged 1 commit into from
Jul 31, 2014

Conversation

jasl
Copy link
Contributor

@jasl jasl commented Jul 28, 2014

No description provided.

@jasl jasl changed the title TokensController inherit ActionController::Metal TokensController and TokenInfoController inherit ActionController::Metal Jul 28, 2014
module Doorkeeper
class ApplicationMetalController < ActionController::Base
MODULES = [
ActionController::RackDelegation,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use 2 spaces for indentation in an array, relative to the start of the line where the left bracket is.

tute added a commit that referenced this pull request Jul 31, 2014
TokensController and TokenInfoController inherit ActionController::Metal
@tute tute merged commit 688137b into doorkeeper-gem:master Jul 31, 2014
@tute
Copy link
Contributor

tute commented Jul 31, 2014

Thank you!

@jasl jasl deleted the refactor-controllers branch July 31, 2014 16:28
@tyler-eon
Copy link

There are no details as to why this change was made. Is there a particular reason for it? I ask because this breaks the ability to use Devise/Warden when invoking resource_owner_from_credentials, or any other actions which execute inside TokensController. Was this a conscious decision to break that functionality?

@igrep
Copy link

igrep commented Nov 4, 2014

@kolorahl +1! I'm also interested in it.

@jasl
Copy link
Contributor Author

jasl commented Nov 4, 2014

@kolorahl @igrep
The original discussion is here

According to learn its git log, it was inherited Metal since 305710d, and changed to inheritApplicationController since 5056e9b with no reason given, so I guess it's just a missing.

Besides, I can't see where invoke resource_owner_from_credentials, could you point it?

@tyler-eon
Copy link

@jasl Looking at the conversation, I can definitely see why you guys got rid of the extra includes now, but I'm still not sure what the benefit of ActionController::Metal is over ActionController::Base. Was there some performance gain to be had, was there erroneous behavior not exhibited in the metal version?

As far as the invocation of resource_owner_from_credentials, I was following the wiki to do a curl command for a password grant. My config code was very simply:

resource_owner_from_credentials do
    current_user
end

When hitting the POST /oauth/tokens endpoint using the password grant credentials I received a Rails error that says there is no method or variable named current_user in Doorkeeper::TokensController. I can confirm this is the the case because Devise and Warden modify ActionController::Base and not ActionController::Metal, so all metal-derived classes do not receive the included helper functionality of Devise or Warden.

@jasl
Copy link
Contributor Author

jasl commented Nov 4, 2014

@kolorahl
Inheriting Metal is consider about performance right.

I will check what you point out, thank for you reporting.

@tyler-eon
Copy link

Sure thing. Let me know if you want me to put this in a bug ticket. I'll let you do a bit of investigation first, though.

@jasl
Copy link
Contributor Author

jasl commented Nov 4, 2014

@kolorahl
Yes, please

@tyler-eon
Copy link

Opened issue #504 in regards to this discussion.

@tute
Copy link
Contributor

tute commented Nov 8, 2014

At the moment it made sense to me as a general rule of thumb, but now I consider it was my mistake, as I didn't have before/after performance tests to compare them. I'd love to have them, and know what's better, for now we don't know if inheriting form Metal is actually better or not (we didn't grab any data).

@jasl
Copy link
Contributor Author

jasl commented Nov 9, 2014

@tute
it's not about performance(although Metal is quicker by theory).

The problem is no comment told why TokenController inherit ApplicationController originally and changed to MetalController and back to ApplicationController again with some no necessary codes, these changes are not break tests.

According to git log and its business, I think it should inherit Metal, it's about design, not performance.

@jasl
Copy link
Contributor Author

jasl commented Nov 9, 2014

Actually spending two months really busy work, I have some free time now.
My next step is learning Doorkeeper's controllers, and thinking how to refactor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants