Sha256: 4ada302886f09d87bdc5bc6d61fc4787fc6b086068c3c7c03f3e546da25635cd

Contents?: true

Size: 807 Bytes

Versions: 15

Compression:

Stored size: 807 Bytes

Contents

module Locomotive
  module Concerns

    # When called, the account_required method enhances the controller by:
    #
    #   - checking if someone is authentified or not.
    #   - setting the right locale for the UI based on the authenticated account.
    #
    module AccountController

      extend ActiveSupport::Concern

      private

      def require_account
        authenticate_locomotive_account!
      end

      def set_back_office_locale
        ::I18n.locale = current_locomotive_account.locale rescue Locomotive.config.default_locale
      end

      public

      module ClassMethods

        def account_required
          class_eval do
            before_action :require_account

            before_action :set_back_office_locale
          end
        end

      end

    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
locomotivecms-4.2.0.alpha2 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-4.2.0.alpha1 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-4.1.1 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-4.1.0 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-4.1.0.rc1 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-4.0.3 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-4.0.2 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-4.0.1 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-4.0.0 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-4.0.0.rc0 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-4.0.0.alpha3 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.4.1 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-4.0.0.alpha2 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-4.0.0.alpha1 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.4.0 app/controllers/locomotive/concerns/account_controller.rb