summaryrefslogtreecommitdiffstats
path: root/settings/ajax/changepersonalpassword.php
diff options
context:
space:
mode:
Diffstat (limited to 'settings/ajax/changepersonalpassword.php')
-rw-r--r--settings/ajax/changepersonalpassword.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/settings/ajax/changepersonalpassword.php b/settings/ajax/changepersonalpassword.php
new file mode 100644
index 00000000000..6c3f5d599ac
--- /dev/null
+++ b/settings/ajax/changepersonalpassword.php
@@ -0,0 +1,24 @@
+<?php
+
+// Check if we are an user
+OC_JSON::callCheck();
+OC_JSON::checkLoggedIn();
+
+// Manually load apps to ensure hooks work correctly (workaround for issue 1503)
+OC_App::loadApps();
+
+$username = OC_User::getUser();
+$password = isset($_POST['personal-password']) ? $_POST['personal-password'] : null;
+$oldPassword = isset($_POST['oldpassword']) ? $_POST['oldpassword'] : '';
+$recoveryPassword = isset($_POST['recoveryPassword']) ? $_POST['recoveryPassword'] : null;
+
+if (!OC_User::checkPassword($username, $oldPassword)) {
+ $l = new \OC_L10n('settings');
+ OC_JSON::error(array("data" => array("message" => $l->t("Wrong password")) ));
+ exit();
+}
+if (!is_null($password) && OC_User::setPassword($username, $password)) {
+ OC_JSON::success();
+} else {
+ OC_JSON::error();
+}