Module: ShopifyApp::LoginProtection

Extended by:
ActiveSupport::Concern
Included in:
AuthenticatedController, SessionsController
Defined in:
lib/shopify_app/controller_concerns/login_protection.rb

Defined Under Namespace

Classes: ShopifyDomainNotFound

Instance Method Summary collapse

Instance Method Details

#login_again_if_different_shopObject


29
30
31
32
33
34
35
# File 'lib/shopify_app/controller_concerns/login_protection.rb', line 29

def 
  if shop_session && params[:shop] && params[:shop].is_a?(String) && (shop_session.url != params[:shop])
    session[:shopify] = nil
    session[:shopify_domain] = nil
    
  end
end

#shop_sessionObject


24
25
26
27
# File 'lib/shopify_app/controller_concerns/login_protection.rb', line 24

def shop_session
  return unless session[:shopify]
  @shop_session ||= ShopifyApp::SessionRepository.retrieve(session[:shopify])
end

#shopify_sessionObject


11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/shopify_app/controller_concerns/login_protection.rb', line 11

def shopify_session
  if shop_session
    begin
      ShopifyAPI::Base.activate_session(shop_session)
      yield
    ensure
      ShopifyAPI::Base.clear_session
    end
  else
    
  end
end