2011-04-18 17:07:14 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Init owncloud
|
|
|
|
require_once('../../lib/base.php');
|
|
|
|
|
|
|
|
// We send json data
|
2011-08-13 06:04:48 +04:00
|
|
|
header( "Content-Type: application/jsonrequest" );
|
2011-04-18 17:07:14 +04:00
|
|
|
|
|
|
|
// Check if we are a user
|
2011-08-13 06:04:48 +04: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 17:07:14 +04:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2011-08-13 06:04:48 +04:00
|
|
|
$username = $_POST["username"];
|
|
|
|
$password = $_POST["password"];
|
2011-04-18 17:07:14 +04:00
|
|
|
|
2011-08-13 06:04:48 +04:00
|
|
|
// Return Success story
|
|
|
|
if( OC_User::setPassword( $username, $password )){
|
|
|
|
echo json_encode( array( "status" => "success", "data" => array( "username" => $username )));
|
2011-04-18 17:07:14 +04:00
|
|
|
}
|
2011-08-13 06:04:48 +04:00
|
|
|
else{
|
|
|
|
echo json_encode( array( "status" => "error", "data" => array( "message" => "Unable to change password" )));
|
2011-04-18 17:07:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|