Module: ShopifyApp::SessionsController

Extended by:
ActiveSupport::Concern
Included in:
SessionsController
Defined in:
lib/shopify_app/sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#callbackObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/shopify_app/sessions_controller.rb', line 13

def callback
  if response = request.env['omniauth.auth']
    shop_name = response.uid
    token = response['credentials']['token']

    sess = ShopifyAPI::Session.new(shop_name, token)
    session[:shopify] = ShopifyApp::SessionRepository.store(sess)
    session[:shopify_domain] = shop_name

    WebhooksManager.queue(shop_name, token) if ShopifyApp.configuration.has_webhooks?

    flash[:notice] = "Logged in"
    redirect_to return_address
  else
    flash[:error] = "Could not log in to Shopify store."
    redirect_to 
  end
end

#createObject



9
10
11
# File 'lib/shopify_app/sessions_controller.rb', line 9

def create
  authenticate
end

#destroyObject



32
33
34
35
36
37
# File 'lib/shopify_app/sessions_controller.rb', line 32

def destroy
  session[:shopify] = nil
  session[:shopify_domain] = nil
  flash[:notice] = "Successfully logged out."
  redirect_to 
end

#newObject



5
6
7
# File 'lib/shopify_app/sessions_controller.rb', line 5

def new
  authenticate if params[:shop].present?
end