Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
Password Class Reference
Inheritance diagram for Password:
AbstractBackend BackendInterface

Public Member Functions

 __construct (\Magento\Framework\Stdlib\StringUtils $string)
 
 beforeSave ($object)
 
 validate ($object)
 
- Public Member Functions inherited from AbstractBackend
 setAttribute ($attribute)
 
 getAttribute ()
 
 getType ()
 
 isStatic ()
 
 getTable ()
 
 getEntityIdField ()
 
 setValueId ($valueId)
 
 setEntityValueId ($entity, $valueId)
 
 getValueId ()
 
 getEntityValueId ($entity)
 
 getDefaultValue ()
 
 validate ($object)
 
 afterLoad ($object)
 
 beforeSave ($object)
 
 afterSave ($object)
 
 beforeDelete ($object)
 
 afterDelete ($object)
 
 getAffectedFields ($object)
 
 isScalar ()
 

Data Fields

const MIN_PASSWORD_LENGTH = 6
 

Protected Attributes

 $string
 
- Protected Attributes inherited from AbstractBackend
 $_attribute
 
 $_valueId
 
 $_valueIds = []
 
 $_table
 
 $_entityIdField
 
 $_defaultValue = null
 

Detailed Description

Deprecated:
101.0.0 Customer password attribute backend

Definition at line 15 of file Password.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\Stdlib\StringUtils  $string)
Parameters
\Magento\Framework\Stdlib\StringUtils$string

Definition at line 32 of file Password.php.

Member Function Documentation

◆ beforeSave()

beforeSave (   $object)

Special processing before attribute save: a) check some rules for password b) transform temporary attribute 'password' into real attribute 'password_hash'

Parameters
\Magento\Framework\DataObject$object
Returns
void
Exceptions

Implements BackendInterface.

Definition at line 46 of file Password.php.

47  {
48  $password = $object->getPassword();
49 
50  $length = $this->string->strlen($password);
51  if ($length > 0) {
52  if ($length < self::MIN_PASSWORD_LENGTH) {
53  throw new LocalizedException(
54  __(
55  'The password needs at least %1 characters. Create a new password and try again.',
56  self::MIN_PASSWORD_LENGTH
57  )
58  );
59  }
60 
61  if (trim($password) !== $password) {
62  throw new LocalizedException(
63  __("The password can't begin or end with a space. Verify the password and try again.")
64  );
65  }
66 
67  $object->setPasswordHash($object->hashPassword($password));
68  }
69  }
__()
Definition: __.php:13

◆ validate()

validate (   $object)
Deprecated:
101.0.0
Parameters
\Magento\Framework\DataObject$object
Returns
bool

Definition at line 76 of file Password.php.

77  {
78  $password = $object->getPassword();
79  if ($password && $password === $object->getPasswordConfirm()) {
80  return true;
81  }
82 
83  return parent::validate($object);
84  }

Field Documentation

◆ $string

$string
protected

Definition at line 27 of file Password.php.

◆ MIN_PASSWORD_LENGTH

const MIN_PASSWORD_LENGTH = 6

Min password length

Definition at line 20 of file Password.php.


The documentation for this class was generated from the following file: