Sha256: b79cb121cde2ecaca4c75b22268c5b341d5a3dcb64bf7db2a0f3ca3fe2b4cf97

Contents?: true

Size: 1.11 KB

Versions: 14

Compression:

Stored size: 1.11 KB

Contents

class SessionsController < ApplicationController
  include ShopifyApp::SessionsConcern

  def referral
    cookies[DiscoApp::SOURCE_COOKIE_KEY] = params[:source] if params[:source].present?
    cookies[DiscoApp::CODE_COOKIE_KEY] = params[:code] if params[:code].present?
    redirect_to root_path
  end

  def failure
    flash[:notice] = 'There was an issue while trying to authenticate, please retry'
    redirect_to root_path
  end

  protected

    # Override the authenticate method to allow skipping OAuth in development
    # mode. Skipping OAuth still requires a shop with Shopify domain specified
    # by the `shop` parameter to be present in the local database.
    def authenticate
      if Rails.env.development? and DiscoApp.configuration.skip_oauth?
        shop = DiscoApp::Shop.find_by_shopify_domain!(sanitized_shop_name)

        sess = ShopifyAPI::Session.new(shop.shopify_domain, shop.shopify_token)
        session[:shopify] = ShopifyApp::SessionRepository.store(sess)
        session[:shopify_domain] = sanitized_shop_name

        redirect_to disco_app.frame_path and return
      end
      super
    end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
disco_app-0.12.5 app/controllers/sessions_controller.rb
disco_app-0.12.6 app/controllers/sessions_controller.rb
disco_app-0.12.7 app/controllers/sessions_controller.rb
disco_app-0.13.0 app/controllers/sessions_controller.rb
disco_app-0.13.1 app/controllers/sessions_controller.rb
disco_app-0.13.2 app/controllers/sessions_controller.rb
disco_app-0.13.3 app/controllers/sessions_controller.rb
disco_app-0.13.4 app/controllers/sessions_controller.rb
disco_app-0.13.5 app/controllers/sessions_controller.rb
disco_app-0.13.6 app/controllers/sessions_controller.rb
disco_app-0.13.7 app/controllers/sessions_controller.rb
disco_app-0.13.8 app/controllers/sessions_controller.rb
disco_app-0.12.7.pre.puma.pre.3 app/controllers/sessions_controller.rb
disco_app-0.13.6.pre.puma.pre.3 app/controllers/sessions_controller.rb