mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-11 19:23:01 +02:00
fixes #1356 pwg.images.uploadAsync, move auth code to inc/user.inc.php
In order to avoid loading user context as "guest" and then wait to be in ws_images_uploadAsync function to authenticate and load a new user context. This way we deal with "automatic" authentication in the same place (as apache auth or url auth) and we use the more common user context loading mecanism. Making Community compatible is now much easier. To avoid duplicating too many lines of ws.php into inc/user.inc.php, I have moved the init of ws.php into inc/ws_init.inc.php
This commit is contained in:
@@ -1473,26 +1473,15 @@ function ws_images_uploadAsync($params, &$service)
|
||||
{
|
||||
global $conf, $user, $logger;
|
||||
|
||||
// the username/password parameters have been used in include/user.inc.php
|
||||
// to authenticate the request (a much better time/place than here)
|
||||
|
||||
// additional check for some parameters
|
||||
if (!preg_match('/^[a-fA-F0-9]{32}$/', $params['original_sum']))
|
||||
{
|
||||
return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid original_sum');
|
||||
}
|
||||
|
||||
if (!try_log_user($params['username'], $params['password'], false))
|
||||
{
|
||||
return new PwgError(999, 'Invalid username/password');
|
||||
}
|
||||
|
||||
// build $user
|
||||
// include(PHPWG_ROOT_PATH.'include/user.inc.php');
|
||||
$user = build_user($user['id'], false);
|
||||
|
||||
if (!is_admin())
|
||||
{
|
||||
return new PwgError(401, 'Admin status is required.');
|
||||
}
|
||||
|
||||
if ($params['image_id'] > 0)
|
||||
{
|
||||
$query='
|
||||
|
||||
Reference in New Issue
Block a user