/** * @protected * Check API Key */ public function _secure() { $headers = getallheaders(); $key = $headers['X-Api-Key']; if (!$key) { $this->redirect('/api/failure/12'); } $apiKey = ApiKey::first(['key' => $key]); if (!$apiKey) { $this->redirect('/api/failure/13'); } $ip = Utils::getClientIp(); if (!in_array($ip, $apiKey->ips)) { // $this->redirect('/api/failure/41'); } $this->_org = Organization::first(['_id' => $apiKey->org_id]); if ($this->_org->live !== true) { $this->redirect('/api/failure/42'); } }