Sha256: d755f8732b022c2957dfd267bd28e5f387f072d80eb6b69c1ec5f1193f86fccd

Contents?: true

Size: 881 Bytes

Versions: 20

Compression:

Stored size: 881 Bytes

Contents

# frozen_string_literal: true

module ShopifyApp
  module ShopAccessScopesVerification
    extend ActiveSupport::Concern
    include ShopifyApp::RedirectForEmbedded

    included do
      before_action :login_on_scope_changes
    end

    protected

    def login_on_scope_changes
      if scopes_mismatch?
        if embedded_param?
          redirect_for_embedded
        else
          redirect_to(shop_login)
        end
      end
    end

    private

    def scopes_mismatch?
      ShopifyApp.configuration.shop_access_scopes_strategy.update_access_scopes?(current_shopify_domain)
    end

    def current_shopify_domain
      return if params[:shop].blank?

      ShopifyApp::Utils.sanitize_shop_domain(params[:shop])
    end

    def shop_login
      ShopifyApp::Utils.shop_login_url(shop: params[:shop], host: params[:host], return_to: request.fullpath)
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
shopify_app-22.0.1 app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb
shopify_app-22.00.0 app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb
shopify_app-21.10.0 app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb
shopify_app-21.9.0 app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb
shopify_app-21.8.1 app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb
shopify_app-21.8.0 app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb
shopify_app-21.7.0 app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb
shopify_app-21.6.0 app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb
shopify_app-21.5.0 app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb
shopify_app-21.4.1 app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb
shopify_app-21.4.0 app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb
shopify_app-21.3.1 app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb
shopify_app-21.3.0 app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb
shopify_app-21.2.0 app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb
shopify_app-21.1.1 app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb
shopify_app-21.1.0 app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb
shopify_app-21.0.0 app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb
shopify_app-20.2.0 app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb
shopify_app-20.1.1 app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb
shopify_app-20.1.0 app/controllers/concerns/shopify_app/shop_access_scopes_verification.rb