From 952de32b0ce1923185cf86c640dc93886c797578 Mon Sep 17 00:00:00 2001 From: alinakarmacharya Date: Thu, 20 Mar 2025 16:16:19 +1100 Subject: [PATCH 01/24] upgrade shopify api and app --- disco_app.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/disco_app.gemspec b/disco_app.gemspec index d7186ef1..ec80448c 100644 --- a/disco_app.gemspec +++ b/disco_app.gemspec @@ -41,8 +41,8 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'rails_12factor', '~> 0.0.3' s.add_runtime_dependency 'react-rails', '~> 2.5' s.add_runtime_dependency 'sass-rails', '~> 6.0' - s.add_runtime_dependency 'shopify_api', '~> 9.0' - s.add_runtime_dependency 'shopify_app', '~> 12.0.7' + s.add_runtime_dependency 'shopify_api', '~> 14.0.1' + s.add_runtime_dependency 'shopify_app', '~> 22.0.0' s.add_runtime_dependency 'sidekiq', '~> 6.0' s.add_runtime_dependency 'sinatra', '~> 2.0' s.add_runtime_dependency 'turbolinks', '~> 5.2' From cf2398b8433298118cba84a4139bce173a957628 Mon Sep 17 00:00:00 2001 From: alinakarmacharya Date: Tue, 15 Apr 2025 15:57:30 +1000 Subject: [PATCH 02/24] add methods for the session storage --- VERSION | 2 +- app/models/disco_app/session_storage.rb | 9 +++++++++ initialise.sh | 2 +- lib/disco_app/version.rb | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 1cf0537c..41915c79 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.19.0 +0.19.1 diff --git a/app/models/disco_app/session_storage.rb b/app/models/disco_app/session_storage.rb index 3ce832ed..cf8e4a7a 100644 --- a/app/models/disco_app/session_storage.rb +++ b/app/models/disco_app/session_storage.rb @@ -17,5 +17,14 @@ def self.retrieve(id) nil end + def self.retrieve_by_shopify_domain(shopify_domain) + Shop.find_by(shopify_domain: shopify_domain) + end + + def self.destroy_by_shopify_domain(shopify_domain) + Shop.find_by(shopify_domain: shopify_domain).destroy + rescue ActiveRecord::RecordNotFound + nil + end end end diff --git a/initialise.sh b/initialise.sh index 83f68f40..cd877413 100755 --- a/initialise.sh +++ b/initialise.sh @@ -24,7 +24,7 @@ fi APP_NAME="$1" RAILS_VERSION="${RAILS_VERSION:-6.0.2}" NODE_VERSION="${NODE_VERSION:-13.7.0}" -DISCO_APP_VERSION="${DISCO_APP_VERSION:-0.19.0}" +DISCO_APP_VERSION="${DISCO_APP_VERSION:-0.19.1}" if [ -z $APP_NAME ]; then echo '' diff --git a/lib/disco_app/version.rb b/lib/disco_app/version.rb index e240fa04..04033656 100644 --- a/lib/disco_app/version.rb +++ b/lib/disco_app/version.rb @@ -1,5 +1,5 @@ module DiscoApp - VERSION = '0.19.0'.freeze + VERSION = '0.19.1'.freeze end From 63f2095e957cac54d23bcc8378ce96c3a3482da2 Mon Sep 17 00:00:00 2001 From: alinakarmacharya Date: Tue, 15 Apr 2025 16:12:27 +1000 Subject: [PATCH 03/24] create and destroy session --- app/models/disco_app/session_storage.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/models/disco_app/session_storage.rb b/app/models/disco_app/session_storage.rb index cf8e4a7a..c0816e7e 100644 --- a/app/models/disco_app/session_storage.rb +++ b/app/models/disco_app/session_storage.rb @@ -18,13 +18,12 @@ def self.retrieve(id) end def self.retrieve_by_shopify_domain(shopify_domain) - Shop.find_by(shopify_domain: shopify_domain) + shop = Shop.find_by(shopify_domain: shopify_domain) + ShopifyAPI::Session.new(domain: shop.shopify_domain, token: shop.shopify_token, api_version: shop.api_version) end def self.destroy_by_shopify_domain(shopify_domain) - Shop.find_by(shopify_domain: shopify_domain).destroy - rescue ActiveRecord::RecordNotFound - nil + destroy_by(shopify_domain: shopify_domain) end end end From b647bc13b686fb8e1d28706f0f7826c8df9c5bdc Mon Sep 17 00:00:00 2001 From: alinakarmacharya Date: Tue, 15 Apr 2025 16:23:27 +1000 Subject: [PATCH 04/24] assign instance variable shop_session --- app/controllers/disco_app/concerns/authenticated_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/disco_app/concerns/authenticated_controller.rb b/app/controllers/disco_app/concerns/authenticated_controller.rb index ed52d15d..e60ff46d 100644 --- a/app/controllers/disco_app/concerns/authenticated_controller.rb +++ b/app/controllers/disco_app/concerns/authenticated_controller.rb @@ -19,7 +19,7 @@ module DiscoApp::Concerns::AuthenticatedController def auto_login return unless shop_session.nil? && request_hmac_valid? - + @shop_session = shop_session shop = DiscoApp::Shop.find_by(shopify_domain: sanitized_shop_name) return if shop.blank? From b6c1dbd0c0efd81e945bd9121ebcff49cf153eeb Mon Sep 17 00:00:00 2001 From: alinakarmacharya Date: Tue, 15 Apr 2025 16:27:31 +1000 Subject: [PATCH 05/24] set shop session --- .../disco_app/concerns/authenticated_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/disco_app/concerns/authenticated_controller.rb b/app/controllers/disco_app/concerns/authenticated_controller.rb index e60ff46d..03ac3224 100644 --- a/app/controllers/disco_app/concerns/authenticated_controller.rb +++ b/app/controllers/disco_app/concerns/authenticated_controller.rb @@ -4,6 +4,7 @@ module DiscoApp::Concerns::AuthenticatedController include ShopifyApp::LoginProtection included do + before_action :set_shop_session before_action :auto_login before_action :check_shop_whitelist before_action :login_again_if_different_user_or_shop @@ -17,9 +18,12 @@ module DiscoApp::Concerns::AuthenticatedController private + def set_shop_session + @shop_session = shop_session + end + def auto_login return unless shop_session.nil? && request_hmac_valid? - @shop_session = shop_session shop = DiscoApp::Shop.find_by(shopify_domain: sanitized_shop_name) return if shop.blank? @@ -28,7 +32,7 @@ def auto_login end def shopify_shop - if shop_session + if @shop_session = shop_session @shop = DiscoApp::Shop.find_by!(shopify_domain: @shop_session.domain) else redirect_to_login From f87b62cd9ab16e4485336d01d91de86cc7e50952 Mon Sep 17 00:00:00 2001 From: alinakarmacharya Date: Tue, 15 Apr 2025 16:31:08 +1000 Subject: [PATCH 06/24] upgrade version --- VERSION | 2 +- initialise.sh | 2 +- lib/disco_app/version.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 41915c79..61e6e92d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.19.1 +0.19.2 diff --git a/initialise.sh b/initialise.sh index cd877413..cdc24894 100755 --- a/initialise.sh +++ b/initialise.sh @@ -24,7 +24,7 @@ fi APP_NAME="$1" RAILS_VERSION="${RAILS_VERSION:-6.0.2}" NODE_VERSION="${NODE_VERSION:-13.7.0}" -DISCO_APP_VERSION="${DISCO_APP_VERSION:-0.19.1}" +DISCO_APP_VERSION="${DISCO_APP_VERSION:-0.19.2}" if [ -z $APP_NAME ]; then echo '' diff --git a/lib/disco_app/version.rb b/lib/disco_app/version.rb index 04033656..704e899b 100644 --- a/lib/disco_app/version.rb +++ b/lib/disco_app/version.rb @@ -1,5 +1,5 @@ module DiscoApp - VERSION = '0.19.1'.freeze + VERSION = '0.19.2'.freeze end From 3129d6e50553b3b27e91fee827ba96c3bb3f9658 Mon Sep 17 00:00:00 2001 From: alinakarmacharya Date: Tue, 15 Apr 2025 16:35:18 +1000 Subject: [PATCH 07/24] use new session --- app/models/disco_app/session_storage.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/disco_app/session_storage.rb b/app/models/disco_app/session_storage.rb index c0816e7e..2f4eb04c 100644 --- a/app/models/disco_app/session_storage.rb +++ b/app/models/disco_app/session_storage.rb @@ -12,14 +12,14 @@ def self.retrieve(id) return unless id shop = Shop.find(id) - ShopifyAPI::Session.new(domain: shop.shopify_domain, token: shop.shopify_token, api_version: shop.api_version) + ShopifyAPI::Auth::Session.new(domain: shop.shopify_domain, token: shop.shopify_token, api_version: shop.api_version) rescue ActiveRecord::RecordNotFound nil end def self.retrieve_by_shopify_domain(shopify_domain) shop = Shop.find_by(shopify_domain: shopify_domain) - ShopifyAPI::Session.new(domain: shop.shopify_domain, token: shop.shopify_token, api_version: shop.api_version) + ShopifyAPI::Auth::Session.new(domain: shop.shopify_domain, token: shop.shopify_token, api_version: shop.api_version) end def self.destroy_by_shopify_domain(shopify_domain) From 16ee7506ee47b3649f0c12f9f79e40b6e49e4830 Mon Sep 17 00:00:00 2001 From: alinakarmacharya Date: Tue, 15 Apr 2025 16:35:58 +1000 Subject: [PATCH 08/24] upgrade version --- VERSION | 2 +- initialise.sh | 2 +- lib/disco_app/version.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 61e6e92d..b72b05ed 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.19.2 +0.19.3 diff --git a/initialise.sh b/initialise.sh index cdc24894..2409c394 100755 --- a/initialise.sh +++ b/initialise.sh @@ -24,7 +24,7 @@ fi APP_NAME="$1" RAILS_VERSION="${RAILS_VERSION:-6.0.2}" NODE_VERSION="${NODE_VERSION:-13.7.0}" -DISCO_APP_VERSION="${DISCO_APP_VERSION:-0.19.2}" +DISCO_APP_VERSION="${DISCO_APP_VERSION:-0.19.3}" if [ -z $APP_NAME ]; then echo '' diff --git a/lib/disco_app/version.rb b/lib/disco_app/version.rb index 704e899b..db263918 100644 --- a/lib/disco_app/version.rb +++ b/lib/disco_app/version.rb @@ -1,5 +1,5 @@ module DiscoApp - VERSION = '0.19.2'.freeze + VERSION = '0.19.3'.freeze end From e6a2ae27f0a45920ee41c71d14785d970fb65e98 Mon Sep 17 00:00:00 2001 From: alinakarmacharya Date: Tue, 15 Apr 2025 16:41:57 +1000 Subject: [PATCH 09/24] fix session auth --- VERSION | 2 +- app/models/disco_app/session_storage.rb | 4 ++-- initialise.sh | 2 +- lib/disco_app/version.rb | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index b72b05ed..c0b8d590 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.19.3 +0.19.4 diff --git a/app/models/disco_app/session_storage.rb b/app/models/disco_app/session_storage.rb index 2f4eb04c..91dc7dc9 100644 --- a/app/models/disco_app/session_storage.rb +++ b/app/models/disco_app/session_storage.rb @@ -12,14 +12,14 @@ def self.retrieve(id) return unless id shop = Shop.find(id) - ShopifyAPI::Auth::Session.new(domain: shop.shopify_domain, token: shop.shopify_token, api_version: shop.api_version) + ShopifyAPI::Auth::Session.new(shop: shop, access_token: shop.shopify_token) rescue ActiveRecord::RecordNotFound nil end def self.retrieve_by_shopify_domain(shopify_domain) shop = Shop.find_by(shopify_domain: shopify_domain) - ShopifyAPI::Auth::Session.new(domain: shop.shopify_domain, token: shop.shopify_token, api_version: shop.api_version) + ShopifyAPI::Auth::Session.new(shop: shop, access_token: shop.shopify_token) end def self.destroy_by_shopify_domain(shopify_domain) diff --git a/initialise.sh b/initialise.sh index 2409c394..5a13ce0c 100755 --- a/initialise.sh +++ b/initialise.sh @@ -24,7 +24,7 @@ fi APP_NAME="$1" RAILS_VERSION="${RAILS_VERSION:-6.0.2}" NODE_VERSION="${NODE_VERSION:-13.7.0}" -DISCO_APP_VERSION="${DISCO_APP_VERSION:-0.19.3}" +DISCO_APP_VERSION="${DISCO_APP_VERSION:-0.19.4}" if [ -z $APP_NAME ]; then echo '' diff --git a/lib/disco_app/version.rb b/lib/disco_app/version.rb index db263918..7d8b718e 100644 --- a/lib/disco_app/version.rb +++ b/lib/disco_app/version.rb @@ -1,5 +1,5 @@ module DiscoApp - VERSION = '0.19.3'.freeze + VERSION = '0.19.4'.freeze end From 6c3c26ff8be88c50d0ea22a6fc226ff1b7d92b87 Mon Sep 17 00:00:00 2001 From: alinakarmacharya Date: Tue, 15 Apr 2025 16:47:09 +1000 Subject: [PATCH 10/24] upgrade disco app --- VERSION | 2 +- app/models/disco_app/session_storage.rb | 4 ++-- initialise.sh | 2 +- lib/disco_app/version.rb | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index c0b8d590..16235ea2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.19.4 +0.19.5 diff --git a/app/models/disco_app/session_storage.rb b/app/models/disco_app/session_storage.rb index 91dc7dc9..ae18423c 100644 --- a/app/models/disco_app/session_storage.rb +++ b/app/models/disco_app/session_storage.rb @@ -12,14 +12,14 @@ def self.retrieve(id) return unless id shop = Shop.find(id) - ShopifyAPI::Auth::Session.new(shop: shop, access_token: shop.shopify_token) + ShopifyAPI::Auth::Session.new(shop: shop.shopify_domain, access_token: shop.shopify_token) rescue ActiveRecord::RecordNotFound nil end def self.retrieve_by_shopify_domain(shopify_domain) shop = Shop.find_by(shopify_domain: shopify_domain) - ShopifyAPI::Auth::Session.new(shop: shop, access_token: shop.shopify_token) + ShopifyAPI::Auth::Session.new(shop: shop.shopify_domain, access_token: shop.shopify_token) end def self.destroy_by_shopify_domain(shopify_domain) diff --git a/initialise.sh b/initialise.sh index 5a13ce0c..840cd92c 100755 --- a/initialise.sh +++ b/initialise.sh @@ -24,7 +24,7 @@ fi APP_NAME="$1" RAILS_VERSION="${RAILS_VERSION:-6.0.2}" NODE_VERSION="${NODE_VERSION:-13.7.0}" -DISCO_APP_VERSION="${DISCO_APP_VERSION:-0.19.4}" +DISCO_APP_VERSION="${DISCO_APP_VERSION:-0.19.5}" if [ -z $APP_NAME ]; then echo '' diff --git a/lib/disco_app/version.rb b/lib/disco_app/version.rb index 7d8b718e..8c4d8fa7 100644 --- a/lib/disco_app/version.rb +++ b/lib/disco_app/version.rb @@ -1,5 +1,5 @@ module DiscoApp - VERSION = '0.19.4'.freeze + VERSION = '0.19.5'.freeze end From c3598ac3dfc525c5f183c39ce2d4b680ddb22bb3 Mon Sep 17 00:00:00 2001 From: alinakarmacharya Date: Tue, 15 Apr 2025 16:58:38 +1000 Subject: [PATCH 11/24] update session --- VERSION | 2 +- app/controllers/disco_app/concerns/authenticated_controller.rb | 2 +- app/views/layouts/embedded_app.html.erb | 2 +- app/views/layouts/embedded_app_modal.html.erb | 2 +- initialise.sh | 2 +- lib/disco_app/version.rb | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/VERSION b/VERSION index 16235ea2..68d0e0ab 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.19.5 +0.19.6 diff --git a/app/controllers/disco_app/concerns/authenticated_controller.rb b/app/controllers/disco_app/concerns/authenticated_controller.rb index 03ac3224..afc153e6 100644 --- a/app/controllers/disco_app/concerns/authenticated_controller.rb +++ b/app/controllers/disco_app/concerns/authenticated_controller.rb @@ -33,7 +33,7 @@ def auto_login def shopify_shop if @shop_session = shop_session - @shop = DiscoApp::Shop.find_by!(shopify_domain: @shop_session.domain) + @shop = DiscoApp::Shop.find_by!(shopify_domain: @shop_session.shop) else redirect_to_login end diff --git a/app/views/layouts/embedded_app.html.erb b/app/views/layouts/embedded_app.html.erb index 2c2ec8c0..304d8e71 100644 --- a/app/views/layouts/embedded_app.html.erb +++ b/app/views/layouts/embedded_app.html.erb @@ -8,7 +8,7 @@ // Initialise the Shopify App. ShopifyApp.init({ "apiKey": "<%= ShopifyApp.configuration.api_key %>", - "shopOrigin": "<%= "https://#{ @shop_session.domain }" if @shop_session %>", + "shopOrigin": "<%= "https://#{ @shop_session.shop }" if @shop_session %>", "debug": <%= Rails.env.development? ? 'true' : 'false' %> }); diff --git a/app/views/layouts/embedded_app_modal.html.erb b/app/views/layouts/embedded_app_modal.html.erb index dc05e9b1..78a57f1b 100644 --- a/app/views/layouts/embedded_app_modal.html.erb +++ b/app/views/layouts/embedded_app_modal.html.erb @@ -7,7 +7,7 @@ // Initialise the Shopify App. ShopifyApp.init({ "apiKey": "<%= ShopifyApp.configuration.api_key %>", - "shopOrigin": "<%= "https://#{ @shop_session.domain }" if @shop_session %>", + "shopOrigin": "<%= "https://#{ @shop_session.shop }" if @shop_session %>", "debug": <%= Rails.env.development? ? 'true' : 'false' %>, "forceRedirect": false }); diff --git a/initialise.sh b/initialise.sh index 840cd92c..20ea982e 100755 --- a/initialise.sh +++ b/initialise.sh @@ -24,7 +24,7 @@ fi APP_NAME="$1" RAILS_VERSION="${RAILS_VERSION:-6.0.2}" NODE_VERSION="${NODE_VERSION:-13.7.0}" -DISCO_APP_VERSION="${DISCO_APP_VERSION:-0.19.5}" +DISCO_APP_VERSION="${DISCO_APP_VERSION:-0.19.6}" if [ -z $APP_NAME ]; then echo '' diff --git a/lib/disco_app/version.rb b/lib/disco_app/version.rb index 8c4d8fa7..79a0c4e7 100644 --- a/lib/disco_app/version.rb +++ b/lib/disco_app/version.rb @@ -1,5 +1,5 @@ module DiscoApp - VERSION = '0.19.5'.freeze + VERSION = '0.19.6'.freeze end From f779317ed001c58558d8f9909f947fc726f1b326 Mon Sep 17 00:00:00 2001 From: alinakarmacharya Date: Tue, 15 Apr 2025 17:02:58 +1000 Subject: [PATCH 12/24] upgrade disco app --- VERSION | 2 +- app/controllers/disco_app/concerns/authenticated_controller.rb | 1 - initialise.sh | 2 +- lib/disco_app/version.rb | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index 68d0e0ab..082b4352 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.19.6 +0.19.7 diff --git a/app/controllers/disco_app/concerns/authenticated_controller.rb b/app/controllers/disco_app/concerns/authenticated_controller.rb index afc153e6..42c001f8 100644 --- a/app/controllers/disco_app/concerns/authenticated_controller.rb +++ b/app/controllers/disco_app/concerns/authenticated_controller.rb @@ -12,7 +12,6 @@ module DiscoApp::Concerns::AuthenticatedController before_action :check_installed before_action :check_current_subscription before_action :check_active_charge - around_action :shopify_session layout 'embedded_app' end diff --git a/initialise.sh b/initialise.sh index 20ea982e..98281043 100755 --- a/initialise.sh +++ b/initialise.sh @@ -24,7 +24,7 @@ fi APP_NAME="$1" RAILS_VERSION="${RAILS_VERSION:-6.0.2}" NODE_VERSION="${NODE_VERSION:-13.7.0}" -DISCO_APP_VERSION="${DISCO_APP_VERSION:-0.19.6}" +DISCO_APP_VERSION="${DISCO_APP_VERSION:-0.19.7}" if [ -z $APP_NAME ]; then echo '' diff --git a/lib/disco_app/version.rb b/lib/disco_app/version.rb index 79a0c4e7..cd78f85c 100644 --- a/lib/disco_app/version.rb +++ b/lib/disco_app/version.rb @@ -1,5 +1,5 @@ module DiscoApp - VERSION = '0.19.6'.freeze + VERSION = '0.19.7'.freeze end From b28b1a672e5af04775f36de094714be516ecdb35 Mon Sep 17 00:00:00 2001 From: alinakarmacharya Date: Tue, 15 Apr 2025 17:17:40 +1000 Subject: [PATCH 13/24] update --- VERSION | 2 +- app/models/disco_app/session_storage.rb | 3 ++- initialise.sh | 2 +- lib/disco_app/version.rb | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index 082b4352..19c79164 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.19.7 +0.19.8 \ No newline at end of file diff --git a/app/models/disco_app/session_storage.rb b/app/models/disco_app/session_storage.rb index ae18423c..38d1db2e 100644 --- a/app/models/disco_app/session_storage.rb +++ b/app/models/disco_app/session_storage.rb @@ -2,7 +2,7 @@ module DiscoApp class SessionStorage def self.store(session, *args) - shop = Shop.find_or_initialize_by(shopify_domain: session.url) + shop = Shop.find_or_initialize_by(shopify_domain: session.shop) shop.shopify_token = session.token shop.save! shop.id @@ -18,6 +18,7 @@ def self.retrieve(id) end def self.retrieve_by_shopify_domain(shopify_domain) + Rails.logger.info("-----------------------Shopify Domain---------------\n #{shopify_domain}\n-----------") shop = Shop.find_by(shopify_domain: shopify_domain) ShopifyAPI::Auth::Session.new(shop: shop.shopify_domain, access_token: shop.shopify_token) end diff --git a/initialise.sh b/initialise.sh index 98281043..2fe9bf39 100755 --- a/initialise.sh +++ b/initialise.sh @@ -24,7 +24,7 @@ fi APP_NAME="$1" RAILS_VERSION="${RAILS_VERSION:-6.0.2}" NODE_VERSION="${NODE_VERSION:-13.7.0}" -DISCO_APP_VERSION="${DISCO_APP_VERSION:-0.19.7}" +DISCO_APP_VERSION="${DISCO_APP_VERSION:-0.19.8}" if [ -z $APP_NAME ]; then echo '' diff --git a/lib/disco_app/version.rb b/lib/disco_app/version.rb index cd78f85c..f81ca213 100644 --- a/lib/disco_app/version.rb +++ b/lib/disco_app/version.rb @@ -1,5 +1,5 @@ module DiscoApp - VERSION = '0.19.7'.freeze + VERSION = '0.19.8'.freeze end From 6278e92e12ca34d5877426968e1a142ec7c612fa Mon Sep 17 00:00:00 2001 From: alinakarmacharya Date: Tue, 15 Apr 2025 17:25:38 +1000 Subject: [PATCH 14/24] upgrade version --- VERSION | 2 +- app/models/disco_app/session_storage.rb | 3 ++- initialise.sh | 2 +- lib/disco_app/version.rb | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index 19c79164..01d4d4cb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.19.8 \ No newline at end of file +0.19.9 \ No newline at end of file diff --git a/app/models/disco_app/session_storage.rb b/app/models/disco_app/session_storage.rb index 38d1db2e..ea5b8418 100644 --- a/app/models/disco_app/session_storage.rb +++ b/app/models/disco_app/session_storage.rb @@ -19,7 +19,8 @@ def self.retrieve(id) def self.retrieve_by_shopify_domain(shopify_domain) Rails.logger.info("-----------------------Shopify Domain---------------\n #{shopify_domain}\n-----------") - shop = Shop.find_by(shopify_domain: shopify_domain) + shop = DiscoApp::Shop.find_by(shopify_domain: shopify_domain) + Rails.logger.info("-----------------------Shopify Shop---------------\n #{shop}\n-----------") ShopifyAPI::Auth::Session.new(shop: shop.shopify_domain, access_token: shop.shopify_token) end diff --git a/initialise.sh b/initialise.sh index 2fe9bf39..19c61b38 100755 --- a/initialise.sh +++ b/initialise.sh @@ -24,7 +24,7 @@ fi APP_NAME="$1" RAILS_VERSION="${RAILS_VERSION:-6.0.2}" NODE_VERSION="${NODE_VERSION:-13.7.0}" -DISCO_APP_VERSION="${DISCO_APP_VERSION:-0.19.8}" +DISCO_APP_VERSION="${DISCO_APP_VERSION:-0.19.9}" if [ -z $APP_NAME ]; then echo '' diff --git a/lib/disco_app/version.rb b/lib/disco_app/version.rb index f81ca213..24855645 100644 --- a/lib/disco_app/version.rb +++ b/lib/disco_app/version.rb @@ -1,5 +1,5 @@ module DiscoApp - VERSION = '0.19.8'.freeze + VERSION = '0.19.9'.freeze end From d385414807dade646636bdef43c55e1e62ac5b8a Mon Sep 17 00:00:00 2001 From: alinakarmacharya Date: Tue, 15 Apr 2025 17:43:52 +1000 Subject: [PATCH 15/24] add log --- VERSION | 2 +- .../disco_app/concerns/authenticated_controller.rb | 3 +++ app/models/disco_app/session_storage.rb | 6 ++---- initialise.sh | 2 +- lib/disco_app/version.rb | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/VERSION b/VERSION index 01d4d4cb..53b45081 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.19.9 \ No newline at end of file +0.19.10 \ No newline at end of file diff --git a/app/controllers/disco_app/concerns/authenticated_controller.rb b/app/controllers/disco_app/concerns/authenticated_controller.rb index 42c001f8..41f4e82f 100644 --- a/app/controllers/disco_app/concerns/authenticated_controller.rb +++ b/app/controllers/disco_app/concerns/authenticated_controller.rb @@ -31,6 +31,9 @@ def auto_login end def shopify_shop + Rails.logger.info("-------Shop params--------") + Rails.logger.info(params) + Rails.logger.info("-------Shop params End--------") if @shop_session = shop_session @shop = DiscoApp::Shop.find_by!(shopify_domain: @shop_session.shop) else diff --git a/app/models/disco_app/session_storage.rb b/app/models/disco_app/session_storage.rb index ea5b8418..0b53d996 100644 --- a/app/models/disco_app/session_storage.rb +++ b/app/models/disco_app/session_storage.rb @@ -2,7 +2,7 @@ module DiscoApp class SessionStorage def self.store(session, *args) - shop = Shop.find_or_initialize_by(shopify_domain: session.shop) + shop = DiscoApp::Shop.find_or_initialize_by(shopify_domain: session.shop) shop.shopify_token = session.token shop.save! shop.id @@ -11,16 +11,14 @@ def self.store(session, *args) def self.retrieve(id) return unless id - shop = Shop.find(id) + shop = DiscoApp::Shop.find(id) ShopifyAPI::Auth::Session.new(shop: shop.shopify_domain, access_token: shop.shopify_token) rescue ActiveRecord::RecordNotFound nil end def self.retrieve_by_shopify_domain(shopify_domain) - Rails.logger.info("-----------------------Shopify Domain---------------\n #{shopify_domain}\n-----------") shop = DiscoApp::Shop.find_by(shopify_domain: shopify_domain) - Rails.logger.info("-----------------------Shopify Shop---------------\n #{shop}\n-----------") ShopifyAPI::Auth::Session.new(shop: shop.shopify_domain, access_token: shop.shopify_token) end diff --git a/initialise.sh b/initialise.sh index 19c61b38..dc87ce3c 100755 --- a/initialise.sh +++ b/initialise.sh @@ -24,7 +24,7 @@ fi APP_NAME="$1" RAILS_VERSION="${RAILS_VERSION:-6.0.2}" NODE_VERSION="${NODE_VERSION:-13.7.0}" -DISCO_APP_VERSION="${DISCO_APP_VERSION:-0.19.9}" +DISCO_APP_VERSION="${DISCO_APP_VERSION:-0.19.10}" if [ -z $APP_NAME ]; then echo '' diff --git a/lib/disco_app/version.rb b/lib/disco_app/version.rb index 24855645..916e8b77 100644 --- a/lib/disco_app/version.rb +++ b/lib/disco_app/version.rb @@ -1,5 +1,5 @@ module DiscoApp - VERSION = '0.19.9'.freeze + VERSION = '0.19.10'.freeze end From 8e123f7e7259922c9795e22e98f81993f07e26fc Mon Sep 17 00:00:00 2001 From: Todd Price Date: Mon, 28 Apr 2025 12:22:06 +0930 Subject: [PATCH 16/24] Update shopify sessions --- .../disco_app/concerns/authenticated_controller.rb | 11 +++-------- app/controllers/sessions_controller.rb | 2 +- app/models/disco_app/concerns/shop.rb | 2 +- lib/disco_app/session.rb | 2 +- test/test_helper.rb | 4 ++-- 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/app/controllers/disco_app/concerns/authenticated_controller.rb b/app/controllers/disco_app/concerns/authenticated_controller.rb index 41f4e82f..5e0ffb7c 100644 --- a/app/controllers/disco_app/concerns/authenticated_controller.rb +++ b/app/controllers/disco_app/concerns/authenticated_controller.rb @@ -4,7 +4,6 @@ module DiscoApp::Concerns::AuthenticatedController include ShopifyApp::LoginProtection included do - before_action :set_shop_session before_action :auto_login before_action :check_shop_whitelist before_action :login_again_if_different_user_or_shop @@ -17,16 +16,12 @@ module DiscoApp::Concerns::AuthenticatedController private - def set_shop_session - @shop_session = shop_session - end - def auto_login return unless shop_session.nil? && request_hmac_valid? shop = DiscoApp::Shop.find_by(shopify_domain: sanitized_shop_name) return if shop.blank? - session[:shopify] = shop.id + session[:shop_id] = shop.id session[:shopify_domain] = sanitized_shop_name end @@ -34,8 +29,8 @@ def shopify_shop Rails.logger.info("-------Shop params--------") Rails.logger.info(params) Rails.logger.info("-------Shop params End--------") - if @shop_session = shop_session - @shop = DiscoApp::Shop.find_by!(shopify_domain: @shop_session.shop) + if @current_shopify_session + @shop = DiscoApp::Shop.find_by!(shopify_domain: @current_shopify_session.shop) else redirect_to_login end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index df791ab1..7de6cb47 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -21,7 +21,7 @@ def authenticate shop = DiscoApp::Shop.find_by!(shopify_domain: sanitized_shop_name) sess = ShopifyAPI::Session.new(domain: shop.shopify_domain, token: shop.shopify_token, api_version: shop.api_version) - session[:shopify] = ShopifyApp::SessionRepository.store(sess) + session[:shop_id] = ShopifyApp::SessionRepository.store(sess) session[:shopify_domain] = sanitized_shop_name redirect_to(disco_app.frame_path) && return diff --git a/app/models/disco_app/concerns/shop.rb b/app/models/disco_app/concerns/shop.rb index 3ff9d79d..f60f9a21 100644 --- a/app/models/disco_app/concerns/shop.rb +++ b/app/models/disco_app/concerns/shop.rb @@ -3,7 +3,7 @@ module DiscoApp::Concerns::Shop extend ActiveSupport::Concern included do - include ShopifyApp::SessionStorage + include ShopifyApp::ShopSessionStorage include ActionView::Helpers::DateHelper # Define relationships to plans and subscriptions. diff --git a/lib/disco_app/session.rb b/lib/disco_app/session.rb index 12b2af5d..e430bb38 100644 --- a/lib/disco_app/session.rb +++ b/lib/disco_app/session.rb @@ -8,7 +8,7 @@ class Session < ActiveRecord::SessionStore::Session def set_shop_id! return false unless loaded? - write_attribute(:shop_id, data[:shopify] || data['shopify']) + write_attribute(:shop_id, data[:shop_id] || data['shop_id']) end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 1052defa..6676df2f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -62,13 +62,13 @@ class ActiveSupport::TestCase include DiscoApp::Test::FileFixtures def log_in_as(shop) - session[:shopify] = shop.id + session[:shop_id] = shop.id session[:shopify_domain] = shop.shopify_domain session[:api_version] = shop.api_version end def log_out - session[:shopify] = nil + session[:shop_id] = nil session[:shopify_domain] = nil session[:api_version] = nil end From 39f585b208066f7a42e1d73f9705549ff936d9b7 Mon Sep 17 00:00:00 2001 From: Todd Price Date: Mon, 28 Apr 2025 13:33:45 +0930 Subject: [PATCH 17/24] Ensure current_shopify_session is called --- .../disco_app/concerns/authenticated_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/disco_app/concerns/authenticated_controller.rb b/app/controllers/disco_app/concerns/authenticated_controller.rb index 5e0ffb7c..ad8e9672 100644 --- a/app/controllers/disco_app/concerns/authenticated_controller.rb +++ b/app/controllers/disco_app/concerns/authenticated_controller.rb @@ -29,8 +29,8 @@ def shopify_shop Rails.logger.info("-------Shop params--------") Rails.logger.info(params) Rails.logger.info("-------Shop params End--------") - if @current_shopify_session - @shop = DiscoApp::Shop.find_by!(shopify_domain: @current_shopify_session.shop) + if current_shopify_session + @shop = DiscoApp::Shop.find_by!(shopify_domain: current_shopify_session.shop) else redirect_to_login end From dbfe211a8261786b0cc612479fa92eb054f1808f Mon Sep 17 00:00:00 2001 From: Todd Price Date: Mon, 28 Apr 2025 14:06:03 +0930 Subject: [PATCH 18/24] Revert to shop_session --- .../disco_app/concerns/authenticated_controller.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/disco_app/concerns/authenticated_controller.rb b/app/controllers/disco_app/concerns/authenticated_controller.rb index ad8e9672..00e44723 100644 --- a/app/controllers/disco_app/concerns/authenticated_controller.rb +++ b/app/controllers/disco_app/concerns/authenticated_controller.rb @@ -4,6 +4,7 @@ module DiscoApp::Concerns::AuthenticatedController include ShopifyApp::LoginProtection included do + before_action :set_shop_session before_action :auto_login before_action :check_shop_whitelist before_action :login_again_if_different_user_or_shop @@ -16,6 +17,10 @@ module DiscoApp::Concerns::AuthenticatedController private + def set_shop_session + @shop_session = shop_session + end + def auto_login return unless shop_session.nil? && request_hmac_valid? shop = DiscoApp::Shop.find_by(shopify_domain: sanitized_shop_name) @@ -29,8 +34,8 @@ def shopify_shop Rails.logger.info("-------Shop params--------") Rails.logger.info(params) Rails.logger.info("-------Shop params End--------") - if current_shopify_session - @shop = DiscoApp::Shop.find_by!(shopify_domain: current_shopify_session.shop) + if @shop_session + @shop = DiscoApp::Shop.find_by!(shopify_domain: @shop_session.shop) else redirect_to_login end From 268552b1dc2bd79172c4e09ee5d4007daef195cf Mon Sep 17 00:00:00 2001 From: Todd Price Date: Mon, 28 Apr 2025 14:44:46 +0930 Subject: [PATCH 19/24] Add activate_shopify_session action --- .../disco_app/concerns/authenticated_controller.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/controllers/disco_app/concerns/authenticated_controller.rb b/app/controllers/disco_app/concerns/authenticated_controller.rb index 00e44723..1d88ad6a 100644 --- a/app/controllers/disco_app/concerns/authenticated_controller.rb +++ b/app/controllers/disco_app/concerns/authenticated_controller.rb @@ -4,7 +4,6 @@ module DiscoApp::Concerns::AuthenticatedController include ShopifyApp::LoginProtection included do - before_action :set_shop_session before_action :auto_login before_action :check_shop_whitelist before_action :login_again_if_different_user_or_shop @@ -12,15 +11,12 @@ module DiscoApp::Concerns::AuthenticatedController before_action :check_installed before_action :check_current_subscription before_action :check_active_charge + around_action :activate_shopify_session layout 'embedded_app' end private - def set_shop_session - @shop_session = shop_session - end - def auto_login return unless shop_session.nil? && request_hmac_valid? shop = DiscoApp::Shop.find_by(shopify_domain: sanitized_shop_name) @@ -34,8 +30,8 @@ def shopify_shop Rails.logger.info("-------Shop params--------") Rails.logger.info(params) Rails.logger.info("-------Shop params End--------") - if @shop_session - @shop = DiscoApp::Shop.find_by!(shopify_domain: @shop_session.shop) + if shop_session + @shop = DiscoApp::Shop.find_by!(shopify_domain: shop_session.shop) else redirect_to_login end From ccee6fc0cb7649c028f33ed178ec4be0a155e091 Mon Sep 17 00:00:00 2001 From: Todd Price Date: Mon, 28 Apr 2025 16:14:26 +0930 Subject: [PATCH 20/24] Use current_shopify_session --- .../disco_app/concerns/authenticated_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/disco_app/concerns/authenticated_controller.rb b/app/controllers/disco_app/concerns/authenticated_controller.rb index 1d88ad6a..36f8e30c 100644 --- a/app/controllers/disco_app/concerns/authenticated_controller.rb +++ b/app/controllers/disco_app/concerns/authenticated_controller.rb @@ -18,7 +18,7 @@ module DiscoApp::Concerns::AuthenticatedController private def auto_login - return unless shop_session.nil? && request_hmac_valid? + return unless current_shopify_session.nil? && request_hmac_valid? shop = DiscoApp::Shop.find_by(shopify_domain: sanitized_shop_name) return if shop.blank? @@ -30,8 +30,8 @@ def shopify_shop Rails.logger.info("-------Shop params--------") Rails.logger.info(params) Rails.logger.info("-------Shop params End--------") - if shop_session - @shop = DiscoApp::Shop.find_by!(shopify_domain: shop_session.shop) + if current_shopify_session + @shop = DiscoApp::Shop.find_by!(shopify_domain: current_shopify_session.shop) else redirect_to_login end @@ -71,9 +71,9 @@ def request_hmac_valid? end def check_shop_whitelist - return unless shop_session + return unless current_shopify_session return if ENV['WHITELISTED_DOMAINS'].blank? - return if ENV['WHITELISTED_DOMAINS'].include?(shop_session.url) + return if ENV['WHITELISTED_DOMAINS'].include?(current_shopify_session.url) redirect_to_login end From 43edbd544d9f895ffbcad31817b713251e2fea2b Mon Sep 17 00:00:00 2001 From: Todd Price Date: Tue, 29 Apr 2025 11:36:26 +0930 Subject: [PATCH 21/24] Activate shopify session first --- app/controllers/disco_app/concerns/authenticated_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/disco_app/concerns/authenticated_controller.rb b/app/controllers/disco_app/concerns/authenticated_controller.rb index 36f8e30c..1deb8408 100644 --- a/app/controllers/disco_app/concerns/authenticated_controller.rb +++ b/app/controllers/disco_app/concerns/authenticated_controller.rb @@ -4,6 +4,7 @@ module DiscoApp::Concerns::AuthenticatedController include ShopifyApp::LoginProtection included do + around_action :activate_shopify_session before_action :auto_login before_action :check_shop_whitelist before_action :login_again_if_different_user_or_shop @@ -11,7 +12,6 @@ module DiscoApp::Concerns::AuthenticatedController before_action :check_installed before_action :check_current_subscription before_action :check_active_charge - around_action :activate_shopify_session layout 'embedded_app' end From 16cf90f0c779163694ff98ae5a59b34880fd0cc4 Mon Sep 17 00:00:00 2001 From: Todd Price Date: Tue, 29 Apr 2025 12:51:09 +0930 Subject: [PATCH 22/24] Use correct attribute for session storage --- app/models/disco_app/session_storage.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/disco_app/session_storage.rb b/app/models/disco_app/session_storage.rb index 0b53d996..abe6c488 100644 --- a/app/models/disco_app/session_storage.rb +++ b/app/models/disco_app/session_storage.rb @@ -3,7 +3,7 @@ class SessionStorage def self.store(session, *args) shop = DiscoApp::Shop.find_or_initialize_by(shopify_domain: session.shop) - shop.shopify_token = session.token + shop.shopify_token = session.access_token shop.save! shop.id end From e3901a420a35e866d693135a11062ff9994f4208 Mon Sep 17 00:00:00 2001 From: Todd Price Date: Tue, 29 Apr 2025 13:39:07 +0930 Subject: [PATCH 23/24] Update shopify_user key in session --- .../disco_app/concerns/user_authenticated_controller.rb | 2 +- app/controllers/disco_app/user_sessions_controller.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/disco_app/concerns/user_authenticated_controller.rb b/app/controllers/disco_app/concerns/user_authenticated_controller.rb index 629a6c8f..b6ec187a 100644 --- a/app/controllers/disco_app/concerns/user_authenticated_controller.rb +++ b/app/controllers/disco_app/concerns/user_authenticated_controller.rb @@ -10,7 +10,7 @@ module DiscoApp::Concerns::UserAuthenticatedController private def shopify_user - @user = DiscoApp::User.find(session[:shopify_user]) + @user = DiscoApp::User.find(session[:shopify_user_id]) rescue ActiveRecord::RecordNotFound redirect_to disco_app.new_user_session_path end diff --git a/app/controllers/disco_app/user_sessions_controller.rb b/app/controllers/disco_app/user_sessions_controller.rb index 50487c1b..fab9628a 100644 --- a/app/controllers/disco_app/user_sessions_controller.rb +++ b/app/controllers/disco_app/user_sessions_controller.rb @@ -20,7 +20,7 @@ def callback end def destroy - session[:shopify_user] = nil + session[:shopify_user_id] = nil redirect_to root_path end @@ -44,7 +44,7 @@ def authenticate def login_user @user = DiscoApp::User.create_user(associated_user(auth_hash), @shop) - session[:shopify_user] = @user.id + session[:shopify_user_id] = @user.id end def return_address From 65f560cb054d02994e405d00311aaa27a38f6f02 Mon Sep 17 00:00:00 2001 From: Todd Price Date: Tue, 29 Apr 2025 15:35:39 +0930 Subject: [PATCH 24/24] Add logging --- app/models/disco_app/session_storage.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/disco_app/session_storage.rb b/app/models/disco_app/session_storage.rb index abe6c488..0d3de251 100644 --- a/app/models/disco_app/session_storage.rb +++ b/app/models/disco_app/session_storage.rb @@ -3,6 +3,10 @@ class SessionStorage def self.store(session, *args) shop = DiscoApp::Shop.find_or_initialize_by(shopify_domain: session.shop) + Rails.logger.info("-------Session Storage--------") + Rails.logger.info(session.inspect) + Rails.logger.info(shop.inspect) + Rails.logger.info("-------Session Storage End--------") shop.shopify_token = session.access_token shop.save! shop.id