Method: Devise::Models::Lockable::ClassMethods#unlock_access_by_token
- Defined in:
- lib/devise/models/lockable.rb
#unlock_access_by_token(unlock_token) ⇒ Object
Find a user by its 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
175 176 177 178 179 180 181 182 183 |
# File 'lib/devise/models/lockable.rb', line 175 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 |