Sha256: bfc8191cffdaa2a72fe63ff7784e84423d4ca7179f8f4e2cd326952ef3903697
Contents?: true
Size: 963 Bytes
Versions: 11
Compression:
Stored size: 963 Bytes
Contents
# frozen_string_literal: true module ShopifyApp module ShopSessionStorage extend ActiveSupport::Concern include ::ShopifyApp::SessionStorage included do validates :shopify_domain, presence: true, uniqueness: { case_sensitive: false } end class_methods do def store(auth_session, *_args) shop = find_or_initialize_by(shopify_domain: auth_session.shop) shop.shopify_token = auth_session.access_token shop.save! shop.id end def retrieve(id) shop = find_by(id: id) construct_session(shop) end def retrieve_by_shopify_domain(domain) shop = find_by(shopify_domain: domain) construct_session(shop) end private def construct_session(shop) return unless shop ShopifyAPI::Auth::Session.new( shop: shop.shopify_domain, access_token: shop.shopify_token ) end end end end
Version data entries
11 entries across 11 versions & 1 rubygems