Sha256: fe7f500ee268d74e59207917ac5c4b2b840dcf74b1227afd3655973972e99671
Contents?: true
Size: 1.3 KB
Versions: 12
Compression:
Stored size: 1.3 KB
Contents
require 'active_support/dependencies' require 'agilib/token_authenticatable/token_authentication_handler' module Agilib module TokenAuthenticatable extend ActiveSupport::Concern mattr_accessor :secure_token @@secure_token = true mattr_accessor :auth_params @@auth_params = { :user_token => :user_token, :user_email => :user_email } mattr_accessor :login_params @@login_params = { :login => :email, :password => :password } mattr_accessor :route @@route = "/tokens" included do private :generate_authentication_token end def ensure_authentication_token if authentication_token.blank? self.authentication_token = generate_authentication_token end end def generate_authentication_token loop do token = Devise.friendly_token break token unless User.where(authentication_token: token).first end end module ClassMethods def agilib_token_authenticatable(options = {}) if Agilib.use_modules[:token_authenticatable].present? include Agilib::TokenAuthenticatable before_save :ensure_authentication_token end end end end end if defined? ActiveRecord ActiveRecord::Base.send :include, Agilib::TokenAuthenticatable end
Version data entries
12 entries across 12 versions & 1 rubygems