Module: Authentication::Logic::ActsAsAuthentic::SingleAccessToken::Methods

Defined in:
lib/auth/logic/acts_as_authentic/single_access_token.rb

Overview

All method, for the single_access token aspect of acts_as_authentic.

This module, as one of the ‘acts_as_authentic_modules`, is only included into an ActiveRecord model if that model calls `acts_as_authentic`.

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/auth/logic/acts_as_authentic/single_access_token.rb', line 39

def self.included(klass)
  return unless klass.column_names.include?("single_access_token")

  klass.class_eval do
    include InstanceMethods
    validates_uniqueness_of :single_access_token,
                            case_sensitive: true,
                            if: :will_save_change_to_single_access_token?

    before_validation :reset_single_access_token, if: :reset_single_access_token?
    if respond_to?(:after_password_set)
      after_password_set(
        :reset_single_access_token,
        if: :change_single_access_token_with_password?
      )
    end
  end
end