Module: Devise::Models::Lockable::ClassMethods
- Defined in:
- lib/devise/models/lockable.rb
Instance Method Summary collapse
- 
  
    
      #lock_strategy_enabled?(strategy)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    Is the lock enabled for the given lock strategy?. 
- 
  
    
      #send_unlock_instructions(attributes = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Attempt to find a user by its email. 
- 
  
    
      #unlock_access_by_token(unlock_token)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Find a user by its unlock token and try to unlock it. 
- 
  
    
      #unlock_strategy_enabled?(strategy)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    Is the unlock enabled for the given unlock strategy?. 
- #unlock_token ⇒ Object
Instance Method Details
#lock_strategy_enabled?(strategy) ⇒ Boolean
Is the lock enabled for the given lock strategy?
| 181 182 183 | # File 'lib/devise/models/lockable.rb', line 181 def lock_strategy_enabled?(strategy) self.lock_strategy == strategy end | 
#send_unlock_instructions(attributes = {}) ⇒ Object
Attempt to find a user by its 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
| 159 160 161 162 163 | # File 'lib/devise/models/lockable.rb', line 159 def send_unlock_instructions(attributes={}) lockable = find_or_initialize_with_errors(unlock_keys, attributes, :not_found) lockable.resend_unlock_token if lockable.persisted? lockable end | 
#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
| 169 170 171 172 173 | # File 'lib/devise/models/lockable.rb', line 169 def unlock_access_by_token(unlock_token) lockable = find_or_initialize_with_error_by(:unlock_token, unlock_token) lockable.unlock_access! if lockable.persisted? lockable end | 
#unlock_strategy_enabled?(strategy) ⇒ Boolean
Is the unlock enabled for the given unlock strategy?
| 176 177 178 | # File 'lib/devise/models/lockable.rb', line 176 def unlock_strategy_enabled?(strategy) [:both, strategy].include?(self.unlock_strategy) end | 
#unlock_token ⇒ Object
| 185 186 187 | # File 'lib/devise/models/lockable.rb', line 185 def unlock_token Devise.friendly_token end |