Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/engine/PhabricatorAuthPasswordEngine.php
Show First 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | public function checkNewPassword( | ||||
if (PhabricatorCommonPasswords::isCommonPassword($raw_password)) { | if (PhabricatorCommonPasswords::isCommonPassword($raw_password)) { | ||||
throw new PhabricatorAuthPasswordException( | throw new PhabricatorAuthPasswordException( | ||||
pht( | pht( | ||||
'The selected password is very weak: it is one of the most common '. | 'The selected password is very weak: it is one of the most common '. | ||||
'passwords in use. Choose a stronger password.'), | 'passwords in use. Choose a stronger password.'), | ||||
pht('Very Weak')); | pht('Very Weak')); | ||||
} | } | ||||
// If we're creating a brand new object (like registering a new user) | |||||
// and it does not have a PHID yet, it isn't possible for it to have any | |||||
// revoked passwords or colliding passwords either, so we can skip these | |||||
// checks. | |||||
if ($this->getObject()->getPHID()) { | |||||
if ($this->isRevokedPassword($password)) { | if ($this->isRevokedPassword($password)) { | ||||
throw new PhabricatorAuthPasswordException( | throw new PhabricatorAuthPasswordException( | ||||
pht( | pht( | ||||
'The password you entered has been revoked. You can not reuse '. | 'The password you entered has been revoked. You can not reuse '. | ||||
'a password which has been revoked. Choose a new password.'), | 'a password which has been revoked. Choose a new password.'), | ||||
pht('Revoked')); | pht('Revoked')); | ||||
} | } | ||||
if (!$this->isUniquePassword($password)) { | if (!$this->isUniquePassword($password)) { | ||||
throw new PhabricatorAuthPasswordException( | throw new PhabricatorAuthPasswordException( | ||||
pht( | pht( | ||||
'The password you entered is the same as another password '. | 'The password you entered is the same as another password '. | ||||
'associated with your account. Each password must be unique.'), | 'associated with your account. Each password must be unique.'), | ||||
pht('Not Unique')); | pht('Not Unique')); | ||||
} | } | ||||
} | } | ||||
} | |||||
public function isValidPassword(PhutilOpaqueEnvelope $envelope) { | public function isValidPassword(PhutilOpaqueEnvelope $envelope) { | ||||
$this->requireSetup(); | $this->requireSetup(); | ||||
$password_type = $this->getPasswordType(); | $password_type = $this->getPasswordType(); | ||||
$passwords = $this->newQuery() | $passwords = $this->newQuery() | ||||
->withPasswordTypes(array($password_type)) | ->withPasswordTypes(array($password_type)) | ||||
▲ Show 20 Lines • Show All 177 Lines • Show Last 20 Lines |