Make sure only admins can change password of other users
This commit is contained in:
@@ -43,6 +43,10 @@ class UserCredentialController extends BaseController
|
|||||||
|
|
||||||
list($valid, $errors) = $this->userValidator->validatePasswordModification($values);
|
list($valid, $errors) = $this->userValidator->validatePasswordModification($values);
|
||||||
|
|
||||||
|
if (! $this->userSession->isAdmin()) {
|
||||||
|
$values['id'] = $this->userSession->getId();
|
||||||
|
}
|
||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
if ($this->userModel->update($values)) {
|
if ($this->userModel->update($values)) {
|
||||||
$this->flash->success(t('Password modified successfully.'));
|
$this->flash->success(t('Password modified successfully.'));
|
||||||
|
|||||||
@@ -116,6 +116,10 @@ class UserValidator extends BaseValidator
|
|||||||
$v = new Validator($values, array_merge($rules, $this->commonPasswordValidationRules()));
|
$v = new Validator($values, array_merge($rules, $this->commonPasswordValidationRules()));
|
||||||
|
|
||||||
if ($v->execute()) {
|
if ($v->execute()) {
|
||||||
|
if (! $this->userSession->isAdmin() && $values['id'] != $this->userSession->getId()) {
|
||||||
|
return array(false, array('current_password' => array('Invalid User ID')));
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->authenticationManager->passwordAuthentication($this->userSession->getUsername(), $values['current_password'], false)) {
|
if ($this->authenticationManager->passwordAuthentication($this->userSession->getUsername(), $values['current_password'], false)) {
|
||||||
return array(true, array());
|
return array(true, array());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user