class NOBSPW::PasswordChecker

Public Class Methods

new(name: nil, username: nil, email: nil, password:) click to toggle source
# File lib/nobspw/password_checker.rb, line 7
def initialize(name: nil, username: nil, email: nil, password:)
  @name, @username, @email, @password = \
    name&.strip, username&.strip, email&.strip, (password || '').strip
end

Public Instance Methods

reasons()
strong?() click to toggle source
# File lib/nobspw/password_checker.rb, line 12
def strong?
  check_password if @strong.nil?
  @strong
end
weak?() click to toggle source
# File lib/nobspw/password_checker.rb, line 17
def weak?
  !strong?
end
weak_password_reasons() click to toggle source
# File lib/nobspw/password_checker.rb, line 21
def weak_password_reasons
  check_password if @weak_password_reasons.nil?
  @weak_password_reasons
end
Also aliased as: reasons

Private Instance Methods

check_password() click to toggle source
# File lib/nobspw/password_checker.rb, line 29
def check_password
  @weak_password_reasons = []
  NOBSPW.configuration.validation_methods.each do |method|
    if send("#{method}")
      @weak_password_reasons << method.to_s.sub(/\?$/, '').to_sym
      break if NOBSPW.configuration.interrupt_validation_for.include?(method)
    end
  end

  @strong = @weak_password_reasons.empty?
end