summaryrefslogtreecommitdiffstats
path: root/settings/changepassword/controller.php
diff options
context:
space:
mode:
Diffstat (limited to 'settings/changepassword/controller.php')
-rw-r--r--settings/changepassword/controller.php11
1 files changed, 4 insertions, 7 deletions
diff --git a/settings/changepassword/controller.php b/settings/changepassword/controller.php
index 4a68636d3f8..69b7ca710a9 100644
--- a/settings/changepassword/controller.php
+++ b/settings/changepassword/controller.php
@@ -89,7 +89,8 @@ class Controller {
$crypt,
\OC::$server->getLogger(),
\OC::$server->getUserSession(),
- \OC::$server->getConfig());
+ \OC::$server->getConfig(),
+ \OC::$server->getUserManager());
$keyManager = new \OCA\Encryption\KeyManager(
$keyStorage,
$crypt,
@@ -113,30 +114,27 @@ class Controller {
$recoveryEnabledForUser = false;
if ($recoveryAdminEnabled) {
$validRecoveryPassword = $keyManager->checkRecoveryPassword($recoveryPassword);
- $recoveryEnabledForUser = $recovery->isRecoveryEnabledForUser();
+ $recoveryEnabledForUser = $recovery->isRecoveryEnabledForUser($username);
}
+ $l = new \OC_L10n('settings');
if ($recoveryEnabledForUser && $recoveryPassword === '') {
- $l = new \OC_L10n('settings');
\OC_JSON::error(array('data' => array(
'message' => $l->t('Please provide an admin recovery password, otherwise all user data will be lost')
)));
} elseif ($recoveryEnabledForUser && ! $validRecoveryPassword) {
- $l = new \OC_L10n('settings');
\OC_JSON::error(array('data' => array(
'message' => $l->t('Wrong admin recovery password. Please check the password and try again.')
)));
} else { // now we know that everything is fine regarding the recovery password, let's try to change the password
$result = \OC_User::setPassword($username, $password, $recoveryPassword);
if (!$result && $recoveryEnabledForUser) {
- $l = new \OC_L10n('settings');
\OC_JSON::error(array(
"data" => array(
"message" => $l->t("Backend doesn't support password change, but the user's encryption key was successfully updated.")
)
));
} elseif (!$result && !$recoveryEnabledForUser) {
- $l = new \OC_L10n('settings');
\OC_JSON::error(array("data" => array( "message" => $l->t("Unable to change password" ) )));
} else {
\OC_JSON::success(array("data" => array( "username" => $username )));
@@ -147,7 +145,6 @@ class Controller {
if (!is_null($password) && \OC_User::setPassword($username, $password)) {
\OC_JSON::success(array('data' => array('username' => $username)));
} else {
- $l = new \OC_L10n('settings');
\OC_JSON::error(array('data' => array('message' => $l->t('Unable to change password'))));
}
}