This commit is contained in:
Yuri Kuznetsov
2021-04-28 10:33:27 +03:00
parent 1ed6099878
commit 28dcfd714e
2 changed files with 9 additions and 5 deletions

View File

@@ -63,8 +63,10 @@ class User extends \Espo\Core\Controllers\Record
throw new BadRequest();
}
return $this->getService('User')
$this->getService('User')
->changePassword($this->getUser()->id, $data->password, true, $data->currentPassword);
return true;
}
public function postActionChangePasswordByRequest($params, $data, $request)

View File

@@ -89,8 +89,12 @@ class User extends Record implements
}
public function changePassword(
string $userId, string $password, bool $checkCurrentPassword = false, ?string $currentPassword = null
) {
string $userId,
string $password,
bool $checkCurrentPassword = false,
?string $currentPassword = null
): void {
$user = $this->getEntityManager()->getEntity('User', $userId);
if (!$user) {
@@ -132,8 +136,6 @@ class User extends Record implements
$user->set('password', $this->hashPassword($password));
$this->getEntityManager()->saveEntity($user);
return true;
}
public function checkPasswordStrength(string $password): bool