cartodb-4.42/lib/carto/base_password_strategy.rb

18 lines
561 B
Ruby
Raw Permalink Normal View History

2024-04-06 13:25:13 +08:00
require_relative 'common_passwords'
module Carto
class BasePasswordStrategy
include Carto::CommonPasswords
def validate(password, password_confirmation, user = nil)
return ["can't be blank"] if password.nil?
errors = []
errors << "doesn't match confirmation" if password != password_confirmation
errors << "can't be a common password" if COMMON_PASSWORDS.include?(password)
errors << "must be different than the user name" if user.try(:username) && user.username.casecmp(password).zero?
errors
end
end
end