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
# File 'lib/shopify_app/sessions_controller.rb', line 13

def callback
  if response = request.env['omniauth.auth']
    sess = ShopifyAPI::Session.new(params[:shop], response['credentials']['token'])
    session[:shopify] = ShopifyApp::SessionRepository.store(sess)
    flash[:notice] = "Logged in"
    redirect_to return_address
  else
    flash[:error] = "Could not log in to Shopify store."
    redirect_to :action => 'new'
  end
end

#createObject



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

def create
  authenticate
end

#destroyObject



25
26
27
28
29
30
# File 'lib/shopify_app/sessions_controller.rb', line 25

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

  redirect_to :action => 'new'
end

#newObject



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

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