Sha256: b2767da7a00ff8be89d41682d5762bb399a87e66e25d9327244f51d6322f3dcc

Contents?: true

Size: 382 Bytes

Versions: 3

Compression:

Stored size: 382 Bytes

Contents

class SessionStorage
  def self.store(session)
    shop = self.find_or_initialize_by(shopify_domain: session.url)
    shop.shopify_token = session.token
    shop.save!
    shop.id
  end

  def self.retrieve(id)
    return unless id
    shop = self.find(id)
    ShopifyAPI::Session.new(shop.shopify_domain, shop.shopify_token)
  rescue ActiveRecord::RecordNotFound
    nil
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shopify_app-6.0.2 lib/generators/shopify_app/shop_model/templates/session_storage.rb
shopify_app-6.0.1 lib/generators/shopify_app/shop_model/templates/session_storage.rb
shopify_app-6.0.0 lib/generators/shopify_app/shop_model/templates/session_storage.rb