}
$generatePasswordResetToken = false;
- if (strlen($password) > 469) {
+ if (strlen($password) > IUserManager::MAX_PASSWORD_LENGTH) {
throw new OCSException('Invalid password value', 101);
}
if ($password === '') {
break;
case self::USER_FIELD_PASSWORD:
try {
- if (strlen($value) > 469) {
+ if (strlen($value) > IUserManager::MAX_PASSWORD_LENGTH) {
throw new OCSException('Invalid password value', 102);
}
if (!$targetUser->canChangePassword()) {
}
try {
- if ($newpassword === null || strlen($newpassword) > 469 || $user->setPassword($newpassword) === false) {
+ if ($newpassword === null || strlen($newpassword) > IUserManager::MAX_PASSWORD_LENGTH || $user->setPassword($newpassword) === false) {
return new JSONResponse([
'status' => 'error',
'data' => [
]);
}
- if (strlen($password) > 469) {
+ if (strlen($password) > IUserManager::MAX_PASSWORD_LENGTH) {
return new JSONResponse([
'status' => 'error',
'data' => [
$this->eventDispatcher->dispatchTyped(new BeforePasswordResetEvent($user, $password));
\OC_Hook::emit('\OC\Core\LostPassword\Controller\LostController', 'pre_passwordReset', ['uid' => $userId, 'password' => $password]);
- if (strlen($password) > 469) {
+ if (strlen($password) > IUserManager::MAX_PASSWORD_LENGTH) {
throw new HintException('Password too long', $this->l10n->t('Password is too long. Maximum allowed length is 469 characters.'));
}
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig;
use OCP\IDBConnection;
+use OCP\IUserManager;
use OCP\Security\ICrypto;
use Psr\Log\LoggerInterface;
$dbToken->setPrivateKey($this->encrypt($privateKey, $token));
if (!is_null($password) && $this->config->getSystemValueBool('auth.storeCryptedPassword', true)) {
- if (strlen($password) > 469) {
+ if (strlen($password) > IUserManager::MAX_PASSWORD_LENGTH) {
throw new \RuntimeException('Trying to save a password with more than 469 characters is not supported. If you want to use big passwords, disable the auth.storeCryptedPassword option in config.php');
}
$dbToken->setPassword($this->encryptPassword($password, $publicKey));
* @since 8.0.0
*/
interface IUserManager {
+
+ /**
+ * @since 26.0.0
+ */
+ public const MAX_PASSWORD_LENGTH = 469;
+
/**
* register a user backend
*