Skip to content
This repository was archived by the owner on Feb 9, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/assets/javascripts/password_strength.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(function(){
var MULTIPLE_NUMBERS_RE = /\d.*?\d.*?\d/;
var MULTIPLE_SYMBOLS_RE = /[!@#$%^&*?_~].*?[!@#$%^&*?_~]/;
var MULTIPLE_SYMBOLS_RE = /[!@#$%^&*?_~-].*?[!@#$%^&*?_~-]/;
var UPPERCASE_LOWERCASE_RE = /([a-z].*[A-Z])|([A-Z].*[a-z])/;
var SYMBOL_RE = /[!@#\$%^&*?_~]/;
var SYMBOL_RE = /[!@#\$%^&*?_~-]/;

function escapeForRegexp(string) {
return (string || "").replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
Expand Down
2 changes: 1 addition & 1 deletion lib/password_strength/active_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def validate_each(record, attribute, value)
:record => record
)
strength.test
record.errors.add(attribute, :too_weak, options) unless PasswordStrength.enabled && strength.valid?(level(record))
record.errors.add(attribute, :too_weak, **options) unless PasswordStrength.enabled && strength.valid?(level(record))
end

def check_validity!
Expand Down
2 changes: 1 addition & 1 deletion lib/password_strength/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module PasswordStrength
module Version # :nodoc: all
MAJOR = 1
MINOR = 1
PATCH = 4
PATCH = 5
STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
end
end
5 changes: 5 additions & 0 deletions test/password_strength_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ QUnit.test("reward password that contains symbols and chars", function(assert) {
assert.equal(strength.scoreFor("symbols_chars"), 15);
});

QUnit.test("reward password that contains '-' symbol and chars", function(assert) {
strength.password = "a-";
assert.equal(strength.scoreFor("symbols_chars"), 15);
});

QUnit.test("detect two-chars repetitions", function(assert) {
assert.equal(strength.repetitions("11221122", 2), 3);
});
Expand Down