51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/devise_zxcvbn/model.rb', line 51
def password_score(user, arg_email=nil)
password = user.respond_to?(:password) ? user.password : user
zxcvbn_weak_words = []
if arg_email
zxcvbn_weak_words += [arg_email, *DeviseZxcvbn::EmailTokeniser.split(arg_email)]
end
if user.respond_to? :email
local_email = user.email
zxcvbn_weak_words += [local_email, *DeviseZxcvbn::EmailTokeniser.split(local_email)]
end
if user.respond_to? :weak_words
local_weak_words = user.weak_words
raise "weak_words must return an Array" unless (local_weak_words.is_a? Array)
zxcvbn_weak_words += local_weak_words
end
zxcvbn_tester.test(password, zxcvbn_weak_words)
end
|