-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix, Avoid checking resources multi times #1452
base: master
Are you sure you want to change the base?
Fix, Avoid checking resources multi times #1452
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the tests
app/controllers/devise_token_auth/concerns/set_user_by_token.rb
Outdated
Show resolved
Hide resolved
@@ -24,6 +24,9 @@ def set_request_start | |||
|
|||
# user auth | |||
def set_user_by_token(mapping = nil) | |||
# Avoid checking resources multi times | |||
return @resource if resource_is_checked?(mapping) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we just use defined?(@resource)
instead of this elaborate check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bd7242f
to
0968c7a
Compare
0968c7a
to
c176baf
Compare
When use devise_token_auth_group the method 'set_user_by_token' has been call multi times per mapping name. so that, resource has found not reused. That will Increase performance.