-
Notifications
You must be signed in to change notification settings - Fork 683
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
Move covered scopes check into strategy #1600
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,11 @@ def update_access_scopes?(user_id: nil, shopify_user_id: nil) | |
"#update_access_scopes? requires user_id or shopify_user_id parameter inputs") | ||
end | ||
|
||
def covered_scopes?(current_shopify_session) | ||
# NOTE: this not Ruby's `covers?` method, it is defined in ShopifyAPI::Auth::AuthScopes | ||
current_shopify_session.scope.to_a.empty? || current_shopify_session.scope.covers?(ShopifyAPI::Context.scope) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to illustrate what
See https://github.com/Shopify/shopify-api-ruby/blob/main/test/auth/auth_scopes_test.rb for details. |
||
end | ||
|
||
private | ||
|
||
def update_access_scopes_for_user_id?(user_id) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,9 +29,7 @@ def activate_shopify_session | |
return redirect_to_login | ||
end | ||
|
||
unless current_shopify_session.scope.to_a.empty? || | ||
current_shopify_session.scope.covers?(ShopifyAPI::Context.scope) | ||
|
||
unless ShopifyApp.configuration.user_access_scopes_strategy.covered_scopes?(current_shopify_session) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should both clauses of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's really possible for a session to have empty scopes, unless there's a bug in the storage code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would expect so. I don't want to change the behaviour though so I'll leave it in. |
||
clear_shopify_session | ||
return redirect_to_login | ||
end | ||
|
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.
Maybe
covers_scopes?
?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.
I like that better.
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.
Done.