module Devise::Models::Lockable::ClassMethods
def lock_strategy_enabled?(strategy)
def lock_strategy_enabled?(strategy) self.lock_strategy == strategy end
def send_unlock_instructions(attributes = {})
with an email not found error.
unlock instructions to it. If not user is found, returns a new user
Attempt to find a user by its unlock keys. If a record is found, send new
def send_unlock_instructions(attributes = {}) lockable = find_or_initialize_with_errors(unlock_keys, attributes, :not_found) lockable.resend_unlock_instructions if lockable.persisted? lockable end
def unlock_access_by_token(unlock_token)
If the user is not locked, creates an error for the user
If no user is found, returns a new user with an error.
Find a user by its unlock token and try to unlock it.
def unlock_access_by_token(unlock_token) original_token = unlock_token unlock_token = Devise.token_generator.digest(self, :unlock_token, unlock_token) lockable = find_or_initialize_with_error_by(:unlock_token, unlock_token) lockable.unlock_access! if lockable.persisted? lockable.unlock_token = original_token lockable end
def unlock_strategy_enabled?(strategy)
def unlock_strategy_enabled?(strategy) self.unlock_strategy == strategy || (self.unlock_strategy == :both && BOTH_STRATEGIES.include?(strategy)) end