Merge pull request #239 from Manawyrm/master
Added authentication for api/radio this uses the API key function already in Cloudlog, note I need to update CloudlogCAT & SatPC32 interface apps for desktop so before those are released I wouldn't use the master till then :)
这个提交包含在:
		
						当前提交
						bdc9a86426
					
				
					共有  1 个文件被更改,包括 7 次插入 和 0 次删除
				
			
		|  | @ -351,6 +351,8 @@ class API extends CI_Controller { | ||||||
| 	function radio() { | 	function radio() { | ||||||
| 		header('Content-type: application/json'); | 		header('Content-type: application/json'); | ||||||
| 
 | 
 | ||||||
|  | 		$this->load->model('api_model'); | ||||||
|  | 
 | ||||||
| 		//$json = '{"radio":"FT-950","frequency":14075,"mode":"SSB","timestamp":"2012/04/07 16:47"}';
 | 		//$json = '{"radio":"FT-950","frequency":14075,"mode":"SSB","timestamp":"2012/04/07 16:47"}';
 | ||||||
| 
 | 
 | ||||||
| 		$this->load->model('cat'); | 		$this->load->model('cat'); | ||||||
|  | @ -360,6 +362,11 @@ class API extends CI_Controller { | ||||||
| 		// Decode JSON and store
 | 		// Decode JSON and store
 | ||||||
| 		$obj = json_decode(file_get_contents("php://input"), true); | 		$obj = json_decode(file_get_contents("php://input"), true); | ||||||
| 
 | 
 | ||||||
|  | 		if(!isset($obj['key']) || $this->api_model->authorize($obj['key']) == 0) { | ||||||
|  | 		   echo json_encode(['status' => 'failed', 'reason' => "missing api key"]); | ||||||
|  | 		   die(); | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
| 		// Store Result to Database
 | 		// Store Result to Database
 | ||||||
| 		$this->cat->update($obj); | 		$this->cat->update($obj); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		正在加载…
	
		在新工单中引用