Kaynağa Gözat

Trac #891: better error reporting when either the parameter auth_user or auth_pwd are missing.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3089 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 11 yıl önce
ebeveyn
işleme
fbf1fca646

+ 8 - 0
application/applicationextension.inc.php

@@ -582,6 +582,14 @@ class RestResult
 	 */
 	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
 	 */
 	const UNSUPPORTED_VERSION = 10;

+ 8 - 0
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