Merge pull request #1379 from onovy/api_json_check
API: Detect wrong JSON and return correct error message
这个提交包含在:
		
						当前提交
						c8efce8e05
					
				
					共有  1 个文件被更改,包括 4 次插入 和 1 次删除
				
			
		| 
						 | 
				
			
			@ -400,7 +400,10 @@ class API extends CI_Controller {
 | 
			
		|||
 | 
			
		||||
		// Decode JSON and store
 | 
			
		||||
		$obj = json_decode(file_get_contents("php://input"), true);
 | 
			
		||||
 | 
			
		||||
		if ($obj === NULL) {
 | 
			
		||||
		    echo json_encode(['status' => 'failed', 'reason' => "wrong JSON"]);
 | 
			
		||||
		    die();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if(!isset($obj['key']) || $this->api_model->authorize($obj['key']) == 0) {
 | 
			
		||||
		   http_response_code(401);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		正在加载…
	
		在新工单中引用