Class: ShopifyAPI::Utils::SessionUtils

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/shopify_api/utils/session_utils.rb

Class Method Summary collapse

Class Method Details

.delete_current_session(auth_header: nil, cookies: nil, is_online: false) ⇒ Object


35
36
37
38
39
40
# File 'lib/shopify_api/utils/session_utils.rb', line 35

def delete_current_session(auth_header: nil, cookies: nil, is_online: false)
  session_id = current_session_id(auth_header, cookies, is_online)
  return false unless session_id

  Context.session_storage.delete_session(session_id)
end

.delete_offline_session(shop:) ⇒ Object


61
62
63
64
# File 'lib/shopify_api/utils/session_utils.rb', line 61

def delete_offline_session(shop:)
  session_id = offline_session_id(shop)
  Context.session_storage.delete_session(session_id)
end

.load_current_session(auth_header: nil, cookies: nil, is_online: false) ⇒ Object


19
20
21
22
23
24
25
26
# File 'lib/shopify_api/utils/session_utils.rb', line 19

def load_current_session(auth_header: nil, cookies: nil, is_online: false)
  return load_private_session if Context.private?

  session_id = current_session_id(auth_header, cookies, is_online)
  return nil unless session_id

  Context.session_storage.load_session(session_id)
end

.load_offline_session(shop:, include_expired: false) ⇒ Object


48
49
50
51
52
53
54
# File 'lib/shopify_api/utils/session_utils.rb', line 48

def load_offline_session(shop:, include_expired: false)
  session_id = offline_session_id(shop)
  session = Context.session_storage.load_session(session_id)
  return nil if session && !include_expired && session.expires && T.must(session.expires) < Time.now

  session
end