Sha256: 287ace9344bbdaa14977ba64c08bdbeaf8abee8020055e7582d46b9646592652

Contents?: true

Size: 1.26 KB

Versions: 19

Compression:

Stored size: 1.26 KB

Contents

module DiscoApp
  module AuthenticatedController
    extend ActiveSupport::Concern

    included do
      before_action :login_again_if_different_shop
      before_action :shopify_shop
      before_action :verify_status
      around_filter :shopify_session
      layout 'embedded_app'
    end

    private

      def shopify_shop
        if shop_session
          @shop = Shop.find_by!(shopify_domain: @shop_session.url)
        else
          redirect_to_login
        end
      end

      def verify_status
        if not (@shop.charge_active? or @shop.charge_waived?)
          redirect_if_not_current_path(disco_app.new_charge_path)
        elsif @shop.charge_accepted?
          redirect_if_not_current_path(disco_app.activate_charge_path)
        elsif @shop.never_installed? or @shop.uninstalled?
          redirect_if_not_current_path(disco_app.install_path)
        elsif @shop.awaiting_install? or @shop.installing?
          redirect_if_not_current_path(disco_app.installing_path)
        elsif @shop.awaiting_uninstall? or @shop.uninstalling?
          redirect_if_not_current_path(disco_app.uninstalling_path)
        end
      end

      def redirect_if_not_current_path(target)
        if request.path != target
          redirect_to target
        end
      end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
disco_app-0.6.0 app/controllers/disco_app/authenticated_controller.rb
disco_app-0.6.1 app/controllers/disco_app/authenticated_controller.rb
disco_app-0.6.2 app/controllers/disco_app/authenticated_controller.rb
disco_app-0.6.3 app/controllers/disco_app/authenticated_controller.rb
disco_app-0.6.4 app/controllers/disco_app/authenticated_controller.rb
disco_app-0.6.5 app/controllers/disco_app/authenticated_controller.rb
disco_app-0.6.6 app/controllers/disco_app/authenticated_controller.rb
disco_app-0.6.7 app/controllers/disco_app/authenticated_controller.rb
disco_app-0.6.8 app/controllers/disco_app/authenticated_controller.rb
disco_app-0.6.9 app/controllers/disco_app/authenticated_controller.rb
disco_app-0.7.0 app/controllers/disco_app/authenticated_controller.rb
disco_app-0.7.1 app/controllers/disco_app/authenticated_controller.rb
disco_app-0.7.2 app/controllers/disco_app/authenticated_controller.rb
disco_app-0.8.0 app/controllers/disco_app/authenticated_controller.rb
disco_app-0.8.1 app/controllers/disco_app/authenticated_controller.rb
disco_app-0.8.2 app/controllers/disco_app/authenticated_controller.rb
disco_app-0.8.3 app/controllers/disco_app/authenticated_controller.rb
disco_app-0.8.4 app/controllers/disco_app/authenticated_controller.rb
disco_app-0.8.5 app/controllers/disco_app/authenticated_controller.rb