我是否需要在 Shopify 应用程序卸载时手动销毁会话?
Do I need to manually destroy a session on Shopify app uninstall?
我正在使用 shopify_app gem。
问题发生在我安装我的应用程序,然后卸载,然后尝试重新安装时。我通过 "app not found" 消息从应用程序 Oauth 登录页面重定向到我的登录商店。
这让我相信卸载应用程序时会话数据可能没有被破坏,但我不确定如何解决这个问题。我假设我不需要 webhook 来销毁会话。
你能发现我的设置有什么问题吗?
routes.rb
Rails.application.routes.draw do
scope '/hooks', :controller => :hooks do
post :new_customer_callback
post :app_uninstalled_callback
end
root :to => 'home#index'
mount ShopifyApp::Engine, at: '/'
end
class SessionsController < ApplicationController
include ShopifyApp::SessionsController
end
class AuthenticatedController < ApplicationController
before_action :login_again_if_different_shop
around_filter :shopify_session
layout ShopifyApp.configuration.embedded_app? ? 'embedded_app' : 'application'
helper_method :current_shop
end
shopify_session_repository.rb
if Rails.configuration.cache_classes
ShopifyApp::SessionRepository.storage = 'Shop'
else
ActionDispatch::Reloader.to_prepare do
ShopifyApp::SessionRepository.storage = 'Shop'
end
end
这只是一个想法。可能是您在重新安装应用程序时没有更新访问令牌吗?
这是因为当您卸载时,访问令牌不再有效,您的应用可能仍在尝试使用数据库中的旧访问令牌。
我正在使用 shopify_app gem。
问题发生在我安装我的应用程序,然后卸载,然后尝试重新安装时。我通过 "app not found" 消息从应用程序 Oauth 登录页面重定向到我的登录商店。
这让我相信卸载应用程序时会话数据可能没有被破坏,但我不确定如何解决这个问题。我假设我不需要 webhook 来销毁会话。
你能发现我的设置有什么问题吗?
routes.rb
Rails.application.routes.draw do
scope '/hooks', :controller => :hooks do
post :new_customer_callback
post :app_uninstalled_callback
end
root :to => 'home#index'
mount ShopifyApp::Engine, at: '/'
end
class SessionsController < ApplicationController
include ShopifyApp::SessionsController
end
class AuthenticatedController < ApplicationController
before_action :login_again_if_different_shop
around_filter :shopify_session
layout ShopifyApp.configuration.embedded_app? ? 'embedded_app' : 'application'
helper_method :current_shop
end
shopify_session_repository.rb
if Rails.configuration.cache_classes
ShopifyApp::SessionRepository.storage = 'Shop'
else
ActionDispatch::Reloader.to_prepare do
ShopifyApp::SessionRepository.storage = 'Shop'
end
end
这只是一个想法。可能是您在重新安装应用程序时没有更新访问令牌吗?
这是因为当您卸载时,访问令牌不再有效,您的应用可能仍在尝试使用数据库中的旧访问令牌。