lib/devise_zxcvbn/model.rb in devise_zxcvbn-1.1.0 vs lib/devise_zxcvbn/model.rb in devise_zxcvbn-1.1.1
- old
+ new
@@ -12,11 +12,16 @@
end
private
def not_weak_password
- weak_words = [self.email] + DeviseZxcvbn::EmailTokeniser.split(self.email)
+ weak_words = if self.email
+ [self.email, *DeviseZxcvbn::EmailTokeniser.split(self.email)]
+ else
+ []
+ end
+
password_score = ::Zxcvbn.test(password, weak_words).score
if password_score < min_password_score
self.errors.add :password, :weak_password, score: password_score, min_password_score: min_password_score
return false
end
@@ -25,6 +30,6 @@
module ClassMethods
Devise::Models.config(self, :min_password_score)
end
end
end
-end
\ No newline at end of file
+end