Sha256: 0e176307513800a1abefb3ea48421a932c37d3806a5df03dfea3d62c7088550a

Contents?: true

Size: 1.09 KB

Versions: 74

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

module ShopifyApp
  # Cookie management helpers required for ITP implementation
  module Itp
    private

    def set_test_cookie
      return unless ShopifyApp.configuration.embedded_app?
      return unless user_agent_can_partition_cookies

      session['shopify.cookies_persist'] = true
    end

    def set_top_level_oauth_cookie
      session['shopify.top_level_oauth'] = true
    end

    def clear_top_level_oauth_cookie
      session.delete('shopify.top_level_oauth')
    end

    def user_agent_is_mobile
      user_agent = BrowserSniffer.new(request.user_agent).browser_info

      user_agent[:name].to_s.match(/Shopify\sMobile/)
    end

    def user_agent_is_pos
      user_agent = BrowserSniffer.new(request.user_agent).browser_info

      user_agent[:name].to_s.match(/Shopify\sPOS/)
    end

    def user_agent_can_partition_cookies
      user_agent = BrowserSniffer.new(request.user_agent).browser_info

      is_safari = user_agent[:name].to_s.match(/Safari/)

      return false unless is_safari

      user_agent[:version].to_s.match(/12\.0/)
    end
  end
end

Version data entries

74 entries across 74 versions & 2 rubygems

Version Path
ruby_shopify_app-1.3.3 lib/ruby_shopify_app/controller_concerns/itp.rb
ruby_shopify_app-1.3.2 lib/ruby_shopify_app/controller_concerns/itp.rb
ruby_shopify_app-1.3.1 lib/ruby_shopify_app/controller_concerns/itp.rb
ruby_shopify_app-1.3.0 lib/ruby_shopify_app/controller_concerns/itp.rb
ruby_shopify_app-1.2.0 lib/ruby_shopify_app/controller_concerns/itp.rb
ruby_shopify_app-1.1.0 lib/ruby_shopify_app/controller_concerns/itp.rb
ruby_shopify_app-1.0.0 lib/shopify_app/controller_concerns/itp.rb
shopify_app-18.1.3 lib/shopify_app/controller_concerns/itp.rb
shopify_app-18.1.2 lib/shopify_app/controller_concerns/itp.rb
shopify_app-18.1.1 lib/shopify_app/controller_concerns/itp.rb
shopify_app-18.1.0 lib/shopify_app/controller_concerns/itp.rb
shopify_app-18.0.4 lib/shopify_app/controller_concerns/itp.rb
shopify_app-18.0.3 lib/shopify_app/controller_concerns/itp.rb
shopify_app-18.0.2 lib/shopify_app/controller_concerns/itp.rb
shopify_app-18.0.1 lib/shopify_app/controller_concerns/itp.rb
shopify_app-18.0.0 lib/shopify_app/controller_concerns/itp.rb
shopify_app-17.2.1 lib/shopify_app/controller_concerns/itp.rb
shopify_app-17.2.0 lib/shopify_app/controller_concerns/itp.rb
shopify_app-17.1.1 lib/shopify_app/controller_concerns/itp.rb
shopify_app-17.1.0 lib/shopify_app/controller_concerns/itp.rb