Class: Workarea::User::RecentPassword

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::SecurePassword, ApplicationDocument
Defined in:
app/models/workarea/user/recent_password.rb

Class Method Summary collapse

Methods included from ApplicationDocument

#releasable?

Methods included from Sidekiq::Callbacks

assert_valid_config!, async, disable, enable, inline, #run_callbacks

Methods included from Mongoid::Document

#embedded_children

Class Method Details

.clean(user) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/workarea/user/recent_password.rb', line 13

def self.clean(user)
  limit = Workarea.config.password_history_length

  if user.recent_passwords.length > limit
    user
      .recent_passwords
      .by_newest
      .to_a
      .first(user.recent_passwords.length - limit)
      .each(&:delete)
  end
end