Skip to content

Commit

Permalink
Fix InMemoryUserSessionStore - user.shopify_user_id does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
zzooeeyy committed Aug 22, 2023
1 parent 0a9dbff commit 2f0725f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Unreleased
* Fix registration of event_bridge and pub_sub webhooks [#1635](https://github.com/Shopify/shopify_app/pull/1635)
* Adds support for adding any number of trial days within `EnsureBilling` by adding the `trial_days` field to `BillingConfiguration`
* Updated AppBridge to 3.7.8 [#1680](https://github.com/Shopify/shopify_app/pull/1680)
* Fix bug in `InMemoryUserSessionStore#store`, this can now be used out of box. [#1716](https://github.com/Shopify/shopify_app/pull/1716)

21.6.0 (July 11, 2023)
----------
Expand Down
2 changes: 1 addition & 1 deletion lib/shopify_app/session/in_memory_user_session_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class InMemoryUserSessionStore < InMemorySessionStore
class << self
def store(session, user)
id = super
repo[user.shopify_user_id] = session
repo[user.id.to_s] = session
id
end

Expand Down
19 changes: 19 additions & 0 deletions test/shopify_app/session/in_memory_user_session_store_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,24 @@ class InMemoryUserSessionStoreTest < ActiveSupport::TestCase
user_id = "abra"
assert_equal "something", InMemoryUserSessionStore.retrieve_by_shopify_user_id(user_id)
end

test "stores a user session by id" do
user_id = 123456
user = ShopifyAPI::Auth::AssociatedUser.new(
id: user_id,
first_name: "firstname",
last_name: "lastname",
email: "email",
email_verified: true,
account_owner: true,
locale: "locale",
collaborator: false,
)
session = ShopifyAPI::Auth::Session.new(shop: "my_shop", associated_user: user)

InMemoryUserSessionStore.store(session, user)

assert_equal session, InMemoryUserSessionStore.retrieve_by_shopify_user_id(user_id.to_s)
end
end
end

0 comments on commit 2f0725f

Please sign in to comment.