Sha256: 8ba85412305a959a7c45dc8b70928c9dcb9e8d7f3742f4ed19d709146286164b

Contents?: true

Size: 1.17 KB

Versions: 27

Compression:

Stored size: 1.17 KB

Contents

module Locomotive
  module Concerns
    module TokenAuthenticationController

      extend ActiveSupport::Concern

      included do

        before_filter :unsafe_token_authentication_params

        def find_record_from_identifier(entity)
          if Locomotive.config.unsafe_token_authentication
            Locomotive::Account.where(authentication_token: params[:locomotive_account_token]).first
          else
            super
          end
        end

      end

      private

      def unsafe_token_authentication_params
        if Locomotive.config.unsafe_token_authentication
          params[:locomotive_account_token] = params[:auth_token]
          params[:locomotive_account_email] = Locomotive::Account.where(authentication_token: params[:auth_token]).first.try(:email)
        end
      end

      public

      module ClassMethods

        def account_required(options = {})
          class_eval do
            acts_as_token_authentication_handler_for Locomotive::Account

            if actions = options[:except]
              skip_before_filter :authenticate_locomotive_account_from_token!, only: :create
            end
          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/token_authentication_controller.rb
locomotivecms-3.3.0.rc3 app/controllers/locomotive/concerns/token_authentication_controller.rb
locomotivecms-3.3.0.rc2 app/controllers/locomotive/concerns/token_authentication_controller.rb
locomotivecms-3.1.2 app/controllers/locomotive/concerns/token_authentication_controller.rb
locomotivecms-3.2.1 app/controllers/locomotive/concerns/token_authentication_controller.rb
locomotivecms-3.3.0.rc1 app/controllers/locomotive/concerns/token_authentication_controller.rb
locomotivecms-3.2.0 app/controllers/locomotive/concerns/token_authentication_controller.rb
locomotivecms-3.2.0.rc2 app/controllers/locomotive/concerns/token_authentication_controller.rb
locomotivecms-3.2.0.rc1 app/controllers/locomotive/concerns/token_authentication_controller.rb
locomotivecms-3.1.1 app/controllers/locomotive/concerns/token_authentication_controller.rb
locomotivecms-3.1.0 app/controllers/locomotive/concerns/token_authentication_controller.rb
locomotivecms-3.1.0.rc3 app/controllers/locomotive/concerns/token_authentication_controller.rb
locomotivecms-3.1.0.rc2 app/controllers/locomotive/concerns/token_authentication_controller.rb
locomotivecms-3.1.0.rc1 app/controllers/locomotive/concerns/token_authentication_controller.rb
locomotivecms-3.0.1 app/controllers/locomotive/concerns/token_authentication_controller.rb
locomotivecms-3.0.0 app/controllers/locomotive/concerns/token_authentication_controller.rb
locomotivecms-3.0.0.rc7 app/controllers/locomotive/concerns/token_authentication_controller.rb
locomotivecms-3.0.0.rc6 app/controllers/locomotive/concerns/token_authentication_controller.rb
locomotivecms-3.0.0.rc5 app/controllers/locomotive/concerns/token_authentication_controller.rb
locomotivecms-3.0.0.rc4 app/controllers/locomotive/concerns/token_authentication_controller.rb