Sha256: e6ef76a90699d784e111f52d44dc4993bd93b4bc96e47496b202cad3dafa6a42

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

require "active_support"
require "password_strength/base"
require "password_strength/engine" if defined?(Rails::Engine)
require "password_strength/active_record"
require "password_strength/validators/windows2008"

module PasswordStrength
  # Test the password strength by applying several rules.
  # The username is required to match its substring in passwords.
  #
  #   strength = PasswordStrength.test("johndoe", "mypass")
  #   strength.weak?
  #   #=> true
  #
  # You can provide an options hash.
  #
  #   strength = PasswordStrength.test("johndoe", "^Str0ng P4ssw0rd$", :exclude => /\s/)
  #   strength.status
  #   #=> :invalid
  #
  #   strength.invalid?
  #   #=> true
  #
  # You can also provide an array.
  #
  #   strength = PasswordStrength.test("johndoe", "^Str0ng P4ssw0rd$", :exclude => [" ", "asdf", "123"])
  #
  def self.test(username, password, options = {})
    strength = Base.new(username, password, options)
    strength.test
    strength
  end

  class << self
    # You can disable PasswordStrength without having to change a single line of code. This is
    # specially great on development environment.
    attr_accessor :enabled
  end

  # Enable verification by default.
  self.enabled = true
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
password_strength-0.4.1 lib/password_strength.rb
password_strength-0.4.0 lib/password_strength.rb