HCLarsen / devise-uncommon_password

Devise extension to prevent users from using a common password.
MIT License
27 stars 20 forks source link

Add nil-check to not_common_password method #13

Closed ramensoup closed 5 years ago

ramensoup commented 5 years ago

This fix prevents the error "undefined method 'downcase' for nil: NilClass" when the user doesn't set the password.

HCLarsen commented 5 years ago

The if: :password_required? already does this job. the not_common_password validation only runs when the Devise gem specifies that passwords are required.

      included do
        validate :not_common_password, if: :password_required?
      end