Merge commit '957482bc9b23949923f7ac4a3dbb8b8b54892603' into seeddms-5.0.x

This commit is contained in:
Uwe Steinmann 2017-10-27 07:38:26 +02:00
commit 43819b205e

View File

@ -966,6 +966,53 @@ function createAccount() { /* {{{ */
return;
} /* }}} */
/**
* Updates the password of an existing Account, the password must be PUT as a md5 string
*
* @param <type> $id The user name or numerical identifier
*/
function changeAccountPassword($id) { /* {{{ */
global $app, $dms, $userobj;
checkIfAdmin();
if ($app->request()->put('password') == null)
{
$app->response()->header('Content-Type', 'application/json');
echo json_encode(array('success'=>false, 'message'=>'You must PUT a new password', 'data'=>''));
return;
}
$newPassword = $app->request()->put('password');
if(is_numeric($id))
$account = $dms->getUser($id);
else {
$account = $dms->getUserByLogin($id);
}
/**
* User not found
*/
if (!$account) {
$app->response()->status(404);
return;
}
$operation = $account->setPwd($newPassword);
if (!$operation){
$app->response()->header('Content-Type', 'application/json');
echo json_encode(array('success'=>false, 'message'=>'', 'data'=>'Could not change password.'));
return;
}
$app->response()->header('Content-Type', 'application/json');
echo json_encode(array('success'=>true, 'message'=>'', 'data'=>''));
return;
} /* }}} */
function getAccountById($id) { /* {{{ */
global $app, $dms, $userobj;
checkIfAdmin();
@ -1389,6 +1436,7 @@ $app->get('/account/locked', 'getLockedDocuments');
$app->post('/accounts', 'createAccount');
$app->get('/accounts/:id', 'getAccountById');
$app->put('/accounts/:id/disable', 'setDisabledAccount');
$app->get('/accounts/:id/password', 'changeAccountPassword');
$app->post('/groups', 'createGroup');
$app->get('/groups/:id', 'getGroup');
$app->put('/groups/:id/addUser', 'addUserToGroup');