Sha256: 4ccd28d968ccd0bcbaaed5ffa0f3e0d3bb187c864e1d6a24aa047f4e8462d027
Contents?: true
Size: 991 Bytes
Versions: 47
Compression:
Stored size: 991 Bytes
Contents
# frozen_string_literal: true module ShopifyApp module UserSessionStorage extend ActiveSupport::Concern include ::ShopifyApp::SessionStorage included do validates :shopify_domain, presence: true end class_methods do def store(auth_session, user) user = find_or_initialize_by(shopify_user_id: user[:id]) user.shopify_token = auth_session.token user.shopify_domain = auth_session.domain user.save! user.id end def retrieve(id) user = find_by(id: id) construct_session(user) end def retrieve_by_shopify_user_id(user_id) user = find_by(shopify_user_id: user_id) construct_session(user) end private def construct_session(user) return unless user ShopifyAPI::Session.new( domain: user.shopify_domain, token: user.shopify_token, api_version: user.api_version, ) end end end end
Version data entries
47 entries across 47 versions & 2 rubygems