diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2014-11-06 11:11:46 +0100 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2014-11-06 11:12:20 +0100 |
commit | 8104a4e24e8aece95e47a2b6d1fdea30420b6dd9 (patch) | |
tree | fc3463a6f0b23c54473b7e9e0fdf76b0ac4dc6cb /apps | |
parent | 3329492766278e1c2af954cfb87c9c8424530170 (diff) | |
download | nextcloud-server-8104a4e24e8aece95e47a2b6d1fdea30420b6dd9.tar.gz nextcloud-server-8104a4e24e8aece95e47a2b6d1fdea30420b6dd9.zip |
check if the provided password is really the current log-in password
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_encryption/ajax/updatePrivateKeyPassword.php | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/apps/files_encryption/ajax/updatePrivateKeyPassword.php b/apps/files_encryption/ajax/updatePrivateKeyPassword.php index f88e9c64dfd..0f182e93831 100644 --- a/apps/files_encryption/ajax/updatePrivateKeyPassword.php +++ b/apps/files_encryption/ajax/updatePrivateKeyPassword.php @@ -18,6 +18,7 @@ use OCA\Encryption; $l = \OC::$server->getL10N('core'); $return = false; +$errorMessage = $l->t('Could not update the private key password.'); $oldPassword = $_POST['oldPassword']; $newPassword = $_POST['newPassword']; @@ -26,6 +27,11 @@ $view = new \OC\Files\View('/'); $session = new \OCA\Encryption\Session($view); $user = \OCP\User::getUser(); +// check new password +$passwordCorrect = \OCP\User::checkPassword($user, $newPassword); + +if ($passwordCorrect !== false) { + $proxyStatus = \OC_FileProxy::$enabled; \OC_FileProxy::$enabled = false; @@ -42,14 +48,22 @@ if ($decryptedKey) { $session->setPrivateKey($decryptedKey); $return = true; } +} else { + $result = false; + $errorMessage = $l->t('The old password was not correct, please try again.'); } \OC_FileProxy::$enabled = $proxyStatus; +} else { + $result = false; + $errorMessage = $l->t('The current log-in password was not correct, please try again.'); +} + // success or failure if ($return) { $session->setInitialized(\OCA\Encryption\Session::INIT_SUCCESSFUL); \OCP\JSON::success(array('data' => array('message' => $l->t('Private key password successfully updated.')))); } 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))); } |