Class: ShopifyApp::CallbackController

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

Overview

Performs login after OAuth completes

Constant Summary

Constants included from EnsureBilling

EnsureBilling::RECURRING_INTERVALS

Constants included from LoginProtection

LoginProtection::ACCESS_TOKEN_REQUIRED_HEADER

Instance Method Summary collapse

Methods included from LoginProtection

#activate_shopify_session, #add_top_level_redirection_headers, #current_shopify_session, #login_again_if_different_user_or_shop, #signal_access_token_required

Instance Method Details

#callbackObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/shopify_app/callback_controller.rb', line 9

def callback
  begin
    api_session, cookie = validated_auth_objects
  rescue => error
    if error.class.module_parent == ShopifyAPI::Errors
      callback_rescue(error)
      return respond_with_error
    else
      raise error
    end
  end

  save_session(api_session) if api_session
  update_rails_cookie(api_session, cookie)

  return respond_with_user_token_flow if start_user_token_flow?(api_session)

  if ShopifyApp::VERSION < "23.0"
    # deprecated in 23.0
    if ShopifyApp.configuration.custom_post_authenticate_tasks.present?
      ShopifyApp.configuration.post_authenticate_tasks.perform(api_session)
    else
      perform_post_authenticate_jobs(api_session)
    end
  else
    ShopifyApp.configuration.post_authenticate_tasks.perform(api_session)
  end
  redirect_to_app if check_billing(api_session)
end