module Authlogic::ActsAsAuthentic::SingleAccessToken::Methods

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`.

Public Class Methods

included(klass) click to toggle source
# File lib/authlogic/acts_as_authentic/single_access_token.rb, line 38
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