Skip to content

Commit

Permalink
Merge pull request #1 from bitzesty/check_min_password_score
Browse files Browse the repository at this point in the history
Error checking on setting the min_password_score
  • Loading branch information
matthewford committed Jan 13, 2014
2 parents 349e881 + 4ecd002 commit afe15a7
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/devise_zxcvbn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,25 @@
require "zxcvbn"

module Devise
mattr_accessor :min_password_score

@@min_password_score = 4

def self.min_password_score
@@min_password_score
end

def self.min_password_score=(score)
if score.is_a?(Integer) && (score >= 0 && score <=4)
if score >= 3
@@min_password_score = score
else
::Rails.logger.warn "[devise_zxcvbn] A score of less than 3 is not recommended."
@@min_password_score = score
end
else
raise "The min_password_score must be an integer and between 0..4"
end
end
end

Devise.add_module :zxcvbnable, :model => "devise_zxcvbn/model"

0 comments on commit afe15a7

Please sign in to comment.