Sha256: 6a5243657627ff4e993c2047c3b02ae3d3c59f16cf2c21119aec4ef069c2700c

Contents?: true

Size: 488 Bytes

Versions: 2

Compression:

Stored size: 488 Bytes

Contents

module TkhAuthenticationActionControllerExtension
  def self.included(base)
    base.send(:include, InstanceMethods) 
    # base.before_filter :authenticate
    # base.after_filter :my_method_2
  end

  module InstanceMethods
    def current_user
      @current_user ||= User.find_by_auth_token!(cookies[:auth_token]) if cookies[:auth_token]
    end

    def authenticate
      redirect_to login_url, alert: t('authentication.warning.login_needed') if current_user.nil?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tkh_authentication-0.0.2 lib/tkh_authentication/tkh_authentication_action_controller_extension.rb
tkh_authentication-0.0.1 lib/tkh_authentication/tkh_authentication_action_controller_extension.rb