mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-03-11 16:35:38 +00:00
Added change password request.
This commit is contained in:
parent
c472db2aad
commit
957482bc9b
|
@ -929,6 +929,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();
|
||||
|
@ -1351,6 +1398,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');
|
||||
|
|
Loading…
Reference in New Issue
Block a user