module CustomFields::Types::Password::Target

Public Instance Methods

_check_password(label, name) click to toggle source
# File lib/custom_fields/types/password.rb, line 69
def _check_password(label, name)
  new_password = instance_variable_get(:"@#{name}")
  confirmation = instance_variable_get(:"@#{name}_confirmation")

  return if new_password.blank?

  if new_password.size < CustomFields::Types::Password::Field::MIN_PASSWORD_LENGTH
    errors.add(name, :too_short, count: CustomFields::Types::Password::Field::MIN_PASSWORD_LENGTH)
  end

  return unless confirmation && confirmation != new_password

  errors.add("#{name}_confirmation", :confirmation, attribute: label || name)
end
_encrypt_password(name, new_password) click to toggle source
# File lib/custom_fields/types/password.rb, line 61
def _encrypt_password(name, new_password)
  return if new_password.blank?

  instance_variable_set(:"@#{name}", new_password)

  send(:"#{name}_hash=", BCrypt::Password.create(new_password))
end
_set_confirmation_password(name, confirmation) click to toggle source
# File lib/custom_fields/types/password.rb, line 57
def _set_confirmation_password(name, confirmation)
  instance_variable_set(:"@#{name}_confirmation", confirmation)
end