Class: ShopifyApp::SessionsController

Inherits:
ActionController::Base
  • Object
show all
Includes:
LoginProtection
Defined in:
app/controllers/shopify_app/sessions_controller.rb

Overview

rubocop:disable Metrics/ClassLength

Instance Method Summary collapse

Methods included from LoginProtection

#login_again_if_different_user_or_shop, #shop_session, #shopify_session

Instance Method Details

#createObject



14
15
16
# File 'app/controllers/shopify_app/sessions_controller.rb', line 14

def create
  authenticate
end

#destroyObject



50
51
52
53
54
# File 'app/controllers/shopify_app/sessions_controller.rb', line 50

def destroy
  reset_session
  flash[:notice] = I18n.t('.logged_out')
  redirect_to()
end

#enable_cookiesObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/shopify_app/sessions_controller.rb', line 18

def enable_cookies
  return unless validate_shop

  render(:enable_cookies, layout: false, locals: {
    does_not_have_storage_access_url: top_level_interaction_path(
      shop: sanitized_shop_name,
      return_to: params[:return_to]
    ),
    has_storage_access_url: (top_level: true),
    app_target_url: granted_storage_access_path(
      shop: sanitized_shop_name,
      return_to: params[:return_to]
    ),
    current_shopify_domain: current_shopify_domain
  })
end

#granted_storage_accessObject



40
41
42
43
44
45
46
47
48
# File 'app/controllers/shopify_app/sessions_controller.rb', line 40

def granted_storage_access
  return unless validate_shop

  session['shopify.granted_storage_access'] = true

  copy_return_to_param_to_session

  redirect_to(return_address_with_params({ shop: @shop }))
end

#newObject



10
11
12
# File 'app/controllers/shopify_app/sessions_controller.rb', line 10

def new
  authenticate if sanitized_shop_name.present?
end

#top_level_interactionObject



35
36
37
38
# File 'app/controllers/shopify_app/sessions_controller.rb', line 35

def top_level_interaction
  @url = (top_level: true)
  validate_shop
end