2011-04-18 13:07:14 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Init owncloud
|
|
|
|
require_once('../../lib/base.php');
|
|
|
|
|
|
|
|
// We send json data
|
2011-08-13 02:04:48 +00:00
|
|
|
header( "Content-Type: application/jsonrequest" );
|
2011-04-18 13:07:14 +00:00
|
|
|
|
|
|
|
// Check if we are a user
|
2011-08-13 02:04:48 +00:00
|
|
|
if( !OC_User::isLoggedIn() || !OC_Group::inGroup( OC_User::getUser(), 'admin' )){
|
|
|
|
echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
|
2011-04-18 13:07:14 +00:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2011-08-27 21:40:41 +00:00
|
|
|
$username = isset($_POST["username"]) ? $_POST["username"] : OC_User::getUser();
|
2011-08-13 02:04:48 +00:00
|
|
|
$password = $_POST["password"];
|
2011-04-18 13:07:14 +00:00
|
|
|
|
2011-08-13 02:04:48 +00:00
|
|
|
// Return Success story
|
|
|
|
if( OC_User::setPassword( $username, $password )){
|
|
|
|
echo json_encode( array( "status" => "success", "data" => array( "username" => $username )));
|
2011-04-18 13:07:14 +00:00
|
|
|
}
|
2011-08-13 02:04:48 +00:00
|
|
|
else{
|
|
|
|
echo json_encode( array( "status" => "error", "data" => array( "message" => "Unable to change password" )));
|
2011-04-18 13:07:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|