Module: Devise::Models::Lockable::ClassMethods

Defined in:
lib/devise/models/lockable.rb

Instance Method Summary collapse

Instance Method Details

#send_unlock_instructions(attributes = {}) ⇒ Object

Attempt to find a user by it’s email. If a record is found, send new unlock instructions to it. If not user is found, returns a new user with an email not found error. Options must contain the user email



140
141
142
143
144
# File 'lib/devise/models/lockable.rb', line 140

def send_unlock_instructions(attributes={})
 lockable = find_or_initialize_with_error_by(:email, attributes[:email], :not_found)
 lockable.resend_unlock! unless lockable.new_record?
 lockable
end

#unlock!(attributes = {}) ⇒ Object

Find a user by it’s unlock token and try to unlock it. If no user is found, returns a new user with an error. If the user is not locked, creates an error for the user Options must have the unlock_token



150
151
152
153
154
# File 'lib/devise/models/lockable.rb', line 150

def unlock!(attributes={})
  lockable = find_or_initialize_with_error_by(:unlock_token, attributes[:unlock_token])
  lockable.unlock! unless lockable.new_record?
  lockable
end