Sha256: 5eea38ac8ae85e07f9037ba547f214116b193c95f9a6f8370e0fba49fb281dfa

Contents?: true

Size: 807 Bytes

Versions: 27

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_filter :require_account

            before_filter :set_back_office_locale
          end
        end

      end

    end

  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
locomotivecms-3.3.0 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.3.0.rc3 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.3.0.rc2 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.1.2 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.2.1 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.3.0.rc1 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.2.0 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.2.0.rc2 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.2.0.rc1 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.1.1 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.1.0 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.1.0.rc3 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.1.0.rc2 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.1.0.rc1 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.0.1 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.0.0 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.0.0.rc7 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.0.0.rc6 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.0.0.rc5 app/controllers/locomotive/concerns/account_controller.rb
locomotivecms-3.0.0.rc4 app/controllers/locomotive/concerns/account_controller.rb