mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-05-01 21:59:58 +03:00
fixes #735, add API method pwg.users.getAuthKey
This commit is contained in:
parent
02275fe275
commit
63932b9390
2 changed files with 36 additions and 0 deletions
|
@ -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
12
ws.php
|
@ -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',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue