Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Sack <kde@jakobsack.de>2011-04-18 17:07:14 +0400
committerJakob Sack <kde@jakobsack.de>2011-04-18 17:07:14 +0400
commitb57823baa5d4f0d23be8d034550a0ffcb788a2ca (patch)
treebfae96c4e0e7b88b072379e3c2addf26a31561c0 /settings/ajax
parent46f1ea14c0af9f64722d44d9390d868c4e060c14 (diff)
Made the "change password" thingie in settings working
Diffstat (limited to 'settings/ajax')
-rw-r--r--settings/ajax/changepassword.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/settings/ajax/changepassword.php b/settings/ajax/changepassword.php
new file mode 100644
index 00000000000..1a9ad73610e
--- /dev/null
+++ b/settings/ajax/changepassword.php
@@ -0,0 +1,35 @@
+<?php
+
+// Init owncloud
+require_once('../../lib/base.php');
+
+// We send json data
+header( "Content-Type: application/jsonrequest" );
+
+// Check if we are a user
+if( !OC_USER::isLoggedIn()){
+ echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
+ exit();
+}
+
+// Get data
+if( !isset( $_POST["password"] ) && !isset( $_POST["oldpassword"] )){
+ echo json_encode( array( "status" => "error", "data" => array( "message" => "You have to enter the old and the new password!" )));
+ exit();
+}
+
+// Check if the old password is correct
+if( !OC_USER::checkPassword( $_SESSION["user_id"], $_POST["oldpassword"] )){
+ echo json_encode( array( "status" => "error", "data" => array( "message" => "Your old password is wrong!" )));
+ exit();
+}
+
+// Change password
+if( OC_USER::setPassword( $_SESSION["user_id"], $_POST["password"] )){
+ echo json_encode( array( "status" => "success", "data" => array( "message" => "Password changed" )));
+}
+else{
+ echo json_encode( array( "status" => "error", "data" => array( "message" => "Unable to change password" )));
+}
+
+?>