Module: Devise::Models::PasswordExpirable::InstanceMethods

Defined in:
lib/devise_security_extension/models/password_expirable.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#need_change_passwordObject

set a fake datetime so a password change is needed



38
39
40
41
42
43
44
45
46
47
# File 'lib/devise_security_extension/models/password_expirable.rb', line 38

def need_change_password
  if self.class.expire_password_after.is_a? Fixnum
    self.password_changed_at = self.class.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!Object

set a fake datetime so a password change is needed and save the record



30
31
32
33
34
35
# File 'lib/devise_security_extension/models/password_expirable.rb', line 30

def need_change_password!
  if self.class.expire_password_after.is_a? Fixnum
    need_change_password
    self.save(:validate => false)
  end
end

#need_change_password?Boolean

is an password change required?

Returns:

  • (Boolean)


21
22
23
24
25
26
27
# File 'lib/devise_security_extension/models/password_expirable.rb', line 21

def need_change_password?
  if self.class.expire_password_after.is_a? Fixnum
    self.password_changed_at.nil? or self.password_changed_at < self.class.expire_password_after.ago
  else
    false
  end
end