cartodb-4.29/lib/carto/standard_password_strategy.rb
2020-06-15 10:58:47 +08:00

20 lines
601 B
Ruby

require_dependency 'carto/base_password_strategy'
module Carto
class StandardPasswordStrategy < BasePasswordStrategy
MIN_PASSWORD_LENGTH = 6
MAX_PASSWORD_LENGTH = 64
def validate(password, password_confirmation, user = nil)
errors = super(password, password_confirmation, user)
return errors if password.nil?
errors << "must be at least #{MIN_PASSWORD_LENGTH} characters long" if password.length < MIN_PASSWORD_LENGTH
errors << "must be at most #{MAX_PASSWORD_LENGTH} characters long" if password.length >= MAX_PASSWORD_LENGTH
errors
end
end
end