Class: ShopifyApp::CallbackController

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

Overview

Performs login after OAuth completes

Constant Summary

Constants included from LoginProtection

LoginProtection::ACCESS_TOKEN_REQUIRED_HEADER

Instance Method Summary collapse

Methods included from LoginProtection

#activate_shopify_session, #current_shopify_session, #login_again_if_different_user_or_shop, #shop_session, #shop_session_by_cookie, #shop_session_by_jwt, #signal_access_token_required, #user_session, #user_session_by_cookie, #user_session_by_jwt

Instance Method Details

#callbackObject



8
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
38
# File 'app/controllers/shopify_app/callback_controller.rb', line 8

def callback
  unless auth_hash
    return respond_with_error
  end

  if jwt_request? && !valid_jwt_auth?
    Rails.logger.debug("[ShopifyApp::CallbackController] Invalid JWT auth detected.")
    return respond_with_error
  end

  if jwt_request?
    Rails.logger.debug("[ShopifyApp::CallbackController] JWT request detected. Setting shopify session...")
    set_shopify_session
    head(:ok)
  else
    Rails.logger.debug("[ShopifyApp::CallbackController] Not a JWT request. Resetting session options...")
    reset_session_options
    set_shopify_session

    if redirect_for_user_token?
      Rails.logger.debug("[ShopifyApp::CallbackController] Redirecting for user token...")
      return redirect_to()
    end

    install_webhooks
    install_scripttags
    perform_after_authenticate_job

    redirect_to(return_address)
  end
end