From b4bc3ad716d564ba317c6e3db32560a1c0df0c8b Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Tue, 25 Feb 2014 13:37:01 +0000 Subject: [PATCH] Trac #891: better error reporting when either the parameter auth_user or auth_pwd are missing. SVN:trunk[3089] --- application/applicationextension.inc.php | 8 ++++++++ webservices/rest.php | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/application/applicationextension.inc.php b/application/applicationextension.inc.php index e748b60a1..2bc81dfe8 100644 --- a/application/applicationextension.inc.php +++ b/application/applicationextension.inc.php @@ -581,6 +581,14 @@ class RestResult * Result: the input structure is not a valid JSON string */ const INVALID_JSON = 4; + /** + * Result: the parameter 'auth_user' is missing, authentication aborted + */ + const MISSING_AUTH_USER = 5; + /** + * Result: the parameter 'auth_pwd' is missing, authentication aborted + */ + const MISSING_AUTH_PWD = 6; /** * Result: no operation is available for the specified version */ diff --git a/webservices/rest.php b/webservices/rest.php index cf943b195..fbe30e696 100644 --- a/webservices/rest.php +++ b/webservices/rest.php @@ -96,7 +96,15 @@ try utils::UseParamFile(); $sAuthUser = utils::ReadParam('auth_user', null, false, 'raw_data'); + if ($sAuthUser === null) + { + throw new Exception("Missing parameter 'auth_user'", RestResult::MISSING_AUTH_USER); + } $sAuthPwd = utils::ReadParam('auth_pwd', null, false, 'raw_data'); + if ($sAuthPwd === null) + { + throw new Exception("Missing parameter 'auth_pwd'", RestResult::MISSING_AUTH_PWD); + } if (UserRights::CheckCredentials($sAuthUser, $sAuthPwd)) { UserRights::Login($sAuthUser); // Login & set the user's language