lib/devise_zxcvbn/model.rb in devise_zxcvbn-1.0.0 vs lib/devise_zxcvbn/model.rb in devise_zxcvbn-1.1.0

- old
+ new

@@ -1,5 +1,7 @@ +require 'devise_zxcvbn/email_tokeniser' + module Devise module Models module Zxcvbnable extend ActiveSupport::Concern @@ -10,10 +12,11 @@ end private def not_weak_password - password_score = ::Zxcvbn.test(password, [self.email]).score + weak_words = [self.email] + DeviseZxcvbn::EmailTokeniser.split(self.email) + 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 end \ No newline at end of file