Sha256: 5320a70898a9c812b2fe748aab91b3fcbdb1e4df2a27c085157bc7b29a4662df

Contents?: true

Size: 382 Bytes

Versions: 10

Compression:

Stored size: 382 Bytes

Contents

class SessionStorage
  def self.store(session)
    shop = Shop.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 = Shop.find(id)
    ShopifyAPI::Session.new(shop.shopify_domain, shop.shopify_token)
  rescue ActiveRecord::RecordNotFound
    nil
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
shopify_app-6.2.1 lib/generators/shopify_app/shop_model/templates/session_storage.rb
shopify_app-6.2.0 lib/generators/shopify_app/shop_model/templates/session_storage.rb
shopify_app-6.1.3 lib/generators/shopify_app/shop_model/templates/session_storage.rb
shopify_app-6.1.2 lib/generators/shopify_app/shop_model/templates/session_storage.rb
shopify_app-6.1.1 lib/generators/shopify_app/shop_model/templates/session_storage.rb
shopify_app-6.1.0 lib/generators/shopify_app/shop_model/templates/session_storage.rb
shopify_app-6.0.6 lib/generators/shopify_app/shop_model/templates/session_storage.rb
shopify_app-6.0.5 lib/generators/shopify_app/shop_model/templates/session_storage.rb
shopify_app-6.0.4 lib/generators/shopify_app/shop_model/templates/session_storage.rb
shopify_app-6.0.3 lib/generators/shopify_app/shop_model/templates/session_storage.rb