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

Add helper method alias to JwtPayload similar to ShopifyApp::JWT #1315

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

zzooeeyy
Copy link
Contributor

@zzooeeyy zzooeeyy commented Apr 22, 2024

Description

Add helper methods to JwtPayload with names similar to ShopifyApp JWT to make deprecation migration easier.

  def shopify_domain
    @payload && ShopifyApp::Utils.sanitize_shop_domain(@payload["dest"])
  end

  def shopify_user_id
    @payload["sub"].to_i if @payload && @payload["sub"]
  end

  def expire_at
    @payload["exp"].to_i if @payload && @payload["exp"]
  end

How has this been tested?

Unit tested the methods to return expected values

Checklist:

  • My commit message follow the pattern described in here
  • I have performed a self-review of my own code.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have updated the project documentation.
  • I have added a changelog line.

@zzooeeyy zzooeeyy marked this pull request as ready for review April 22, 2024 14:12
@zzooeeyy zzooeeyy requested a review from a team as a code owner April 22, 2024 14:12
Copy link
Contributor

@paulomarg paulomarg left a comment

Choose a reason for hiding this comment

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

Just a nit.

CHANGELOG.md Outdated
@@ -7,6 +7,7 @@ Note: For changes to the API, see https://shopify.dev/changelog?filter=api
- [#1314](https://github.com/Shopify/shopify-api-ruby/pull/1314)
- Add new session util method `SessionUtils::session_id_from_shopify_id_token`
- `SessionUtils::current_session_id` now accepts shopify Id token in the format of `Bearer this_token` or just `this_token`
- [#1315](https://github.com/Shopify/shopify-api-ruby/pull/1315) Add helper/alias methods to `ShopifyAPI::Auth::JwtPayload`
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should list the methods here or just give an indication of what their purpose is?

@zzooeeyy zzooeeyy merged commit 3f421a5 into main Apr 22, 2024
10 of 11 checks passed
@zzooeeyy zzooeeyy deleted the jwtpayload-helpers branch April 22, 2024 14:53
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.

None yet

2 participants