(cp 63932b9) fixes #735, add API method pwg.users.getAuthKey

This commit is contained in:
plegall
2018-02-22 14:17:44 +01:00
parent 072ae305f8
commit 6d2f2a1d0d
2 changed files with 36 additions and 0 deletions

View File

@@ -296,6 +296,30 @@ function ws_users_add($params, &$service)
return $service->invoke('pwg.users.getList', array('user_id'=>$user_id));
}
/**
* API method
* Get a new authentication key for a user.
* @param mixed[] $params
* @option int[] user_id
* @option string pwg_token
*/
function ws_users_getAuthKey($params, &$service)
{
if (get_pwg_token() != $params['pwg_token'])
{
return new PwgError(403, 'Invalid security token');
}
$authkey = create_user_auth_key($params['user_id']);
if ($authkey === false)
{
return new PwgError(WS_ERR_INVALID_PARAM, 'invalid user_id');
}
return $authkey;
}
/**
* API method
* Deletes users

12
ws.php
View File

@@ -943,6 +943,18 @@ enabled_high, registration_date, registration_date_string, registration_date_sin
array('admin_only'=>true, 'post_only'=>true)
);
$service->addMethod(
'pwg.users.getAuthKey',
'ws_users_getAuthKey',
array(
'user_id' => array('type'=>WS_TYPE_ID),
'pwg_token' => array(),
),
'Get a new authentication key for a user. Only works for normal/generic users (not admins)',
$ws_functions_root . 'pwg.users.php',
array('admin_only'=>true, 'post_only'=>true)
);
$service->addMethod(
'pwg.users.setInfo',
'ws_users_setInfo',