module Devise::Models::TokenAuthenticatable
def self.included(base)
def self.included(base) base.class_eval do extend ClassMethods before_save :ensure_authentication_token end end
def ensure_authentication_token
def ensure_authentication_token self.reset_authentication_token if self.authentication_token.blank? end
def ensure_authentication_token!
def ensure_authentication_token! self.reset_authentication_token! if self.authentication_token.blank? end
def reset_authentication_token
def reset_authentication_token self.authentication_token = self.class.authentication_token end
def reset_authentication_token!
def reset_authentication_token! reset_authentication_token self.save end
def valid_authentication_token?(incoming_auth_token)
Verifies whether an +incoming_authentication_token+ (i.e. from single access URL)
def valid_authentication_token?(incoming_auth_token) incoming_auth_token.present? && incoming_auth_token == self.authentication_token end