We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4bc8538 commit 190fc74Copy full SHA for 190fc74
lib/shopify_api/auth/jwt_payload.rb
@@ -49,9 +49,7 @@ def shop
49
50
sig { returns(T.nilable(Integer)) }
51
def shopify_user_id
52
- return unless @sub
53
-
54
- @sub.tr("^0-9", "").to_i
+ @sub.to_i if user_id_sub? && admin_session_token?
55
end
56
57
alias_method :eql?, :==
@@ -78,6 +76,16 @@ def decode_token(token, api_secret_key)
78
76
rescue JWT::DecodeError => err
79
77
raise ShopifyAPI::Errors::InvalidJwtTokenError, "Error decoding session token: #{err.message}"
80
+
+ sig { returns(T::Boolean) }
81
+ def admin_session_token?
82
+ @iss.end_with?("/admin")
83
+ end
84
85
86
+ def user_id_sub?
87
+ @sub&.match?(/\A\d+\z/) || false
88
89
90
91
0 commit comments