module Devise::Models::PasswordExpirable
PasswordExpirable
takes care of change password after
Public Instance Methods
expire_password_after()
click to toggle source
# File lib/devise_security_extension/models/password_expirable.rb, line 43 def expire_password_after self.class.expire_password_after end
need_change_password()
click to toggle source
set a fake datetime so a password change is needed
# File lib/devise_security_extension/models/password_expirable.rb, line 32 def need_change_password if self.expire_password_after.is_a? Fixnum or self.expire_password_after.is_a? Float self.password_changed_at = self.expire_password_after.ago end # is date not set it will set default to need set new password next login need_change_password if self.password_changed_at.nil? self.password_changed_at end
need_change_password!()
click to toggle source
set a fake datetime so a password change is needed and save the record
# File lib/devise_security_extension/models/password_expirable.rb, line 24 def need_change_password! if self.expire_password_after.is_a? Fixnum or self.expire_password_after.is_a? Float need_change_password self.save(:validate => false) end end
need_change_password?()
click to toggle source
is an password change required?
# File lib/devise_security_extension/models/password_expirable.rb, line 15 def need_change_password? if self.expire_password_after.is_a? Fixnum or self.expire_password_after.is_a? Float self.password_changed_at.nil? or self.password_changed_at < self.expire_password_after.ago else false end end
Private Instance Methods
update_password_changed()
click to toggle source
is password changed then update password_cahanged_at
# File lib/devise_security_extension/models/password_expirable.rb, line 50 def update_password_changed self.password_changed_at = Time.now if (self.new_record? or self.encrypted_password_changed?) and not self.password_changed_at_changed? end