Merge pull request #11993 from owncloud/enc_repeat_password
[encryption] check if the provided password is really the current log-in password
This commit is contained in:
commit
bb15028a00
|
@ -18,6 +18,7 @@ use OCA\Encryption;
|
||||||
$l = \OC::$server->getL10N('core');
|
$l = \OC::$server->getL10N('core');
|
||||||
|
|
||||||
$return = false;
|
$return = false;
|
||||||
|
$errorMessage = $l->t('Could not update the private key password.');
|
||||||
|
|
||||||
$oldPassword = $_POST['oldPassword'];
|
$oldPassword = $_POST['oldPassword'];
|
||||||
$newPassword = $_POST['newPassword'];
|
$newPassword = $_POST['newPassword'];
|
||||||
|
@ -26,6 +27,11 @@ $view = new \OC\Files\View('/');
|
||||||
$session = new \OCA\Encryption\Session($view);
|
$session = new \OCA\Encryption\Session($view);
|
||||||
$user = \OCP\User::getUser();
|
$user = \OCP\User::getUser();
|
||||||
|
|
||||||
|
// check new password
|
||||||
|
$passwordCorrect = \OCP\User::checkPassword($user, $newPassword);
|
||||||
|
|
||||||
|
if ($passwordCorrect !== false) {
|
||||||
|
|
||||||
$proxyStatus = \OC_FileProxy::$enabled;
|
$proxyStatus = \OC_FileProxy::$enabled;
|
||||||
\OC_FileProxy::$enabled = false;
|
\OC_FileProxy::$enabled = false;
|
||||||
|
|
||||||
|
@ -42,14 +48,22 @@ if ($decryptedKey) {
|
||||||
$session->setPrivateKey($decryptedKey);
|
$session->setPrivateKey($decryptedKey);
|
||||||
$return = true;
|
$return = true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$result = false;
|
||||||
|
$errorMessage = $l->t('The old password was not correct, please try again.');
|
||||||
}
|
}
|
||||||
|
|
||||||
\OC_FileProxy::$enabled = $proxyStatus;
|
\OC_FileProxy::$enabled = $proxyStatus;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$result = false;
|
||||||
|
$errorMessage = $l->t('The current log-in password was not correct, please try again.');
|
||||||
|
}
|
||||||
|
|
||||||
// success or failure
|
// success or failure
|
||||||
if ($return) {
|
if ($return) {
|
||||||
$session->setInitialized(\OCA\Encryption\Session::INIT_SUCCESSFUL);
|
$session->setInitialized(\OCA\Encryption\Session::INIT_SUCCESSFUL);
|
||||||
\OCP\JSON::success(array('data' => array('message' => $l->t('Private key password successfully updated.'))));
|
\OCP\JSON::success(array('data' => array('message' => $l->t('Private key password successfully updated.'))));
|
||||||
} else {
|
} else {
|
||||||
\OCP\JSON::error(array('data' => array('message' => $l->t('Could not update the private key password. Maybe the old password was not correct.'))));
|
\OCP\JSON::error(array('data' => array('message' => $errorMessage)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue