Sha256: 5407ad92cba3690a92380465e718c505eae9cad6c6da028f19eb2d6e7a3b136f

Contents?: true

Size: 779 Bytes

Versions: 9

Compression:

Stored size: 779 Bytes

Contents

# frozen_string_literal: true

module ShopifyApp
  module EnsureAuthenticatedLinks
    extend ActiveSupport::Concern

    included do
      before_action :redirect_to_splash_page, if: :missing_expected_jwt?
    end

    private

    def redirect_to_splash_page
      splash_page_path = root_path(return_to: request.fullpath, shop: current_shopify_domain)
      redirect_to(splash_page_path)
    rescue ShopifyApp::LoginProtection::ShopifyDomainNotFound => error
      Rails.logger.warn("[ShopifyApp::EnsureAuthenticatedLinks] Redirecting to login: [#{error.class}] "\
                         "Could not determine current shop domain")
      redirect_to(ShopifyApp.configuration.login_url)
    end

    def missing_expected_jwt?
      jwt_shopify_domain.blank?
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
shopify_app-18.0.2 app/controllers/concerns/shopify_app/ensure_authenticated_links.rb
shopify_app-18.0.1 app/controllers/concerns/shopify_app/ensure_authenticated_links.rb
shopify_app-18.0.0 app/controllers/concerns/shopify_app/ensure_authenticated_links.rb
shopify_app-17.2.1 app/controllers/concerns/shopify_app/ensure_authenticated_links.rb
shopify_app-17.2.0 app/controllers/concerns/shopify_app/ensure_authenticated_links.rb
shopify_app-17.1.1 app/controllers/concerns/shopify_app/ensure_authenticated_links.rb
shopify_app-17.1.0 app/controllers/concerns/shopify_app/ensure_authenticated_links.rb
shopify_app-17.0.5 app/controllers/concerns/shopify_app/ensure_authenticated_links.rb
shopify_app-17.0.4 app/controllers/concerns/shopify_app/ensure_authenticated_links.rb