| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 12 |
| Lines | 16 |
| Ratio | 100 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php defined('BASEPATH') or exit('No direct script access allowed'); |
||
| 35 | View Code Duplication | public function restore() : void { |
|
| 36 | if($this->ion_auth->logged_in()) { |
||
| 37 | if(!$this->limiter->limit('new_api_key', 10)) { |
||
| 38 | $api_key = $this->User->restore_api_key(); |
||
| 39 | $json = ['api-key' => $api_key]; |
||
| 40 | |||
| 41 | $this->output |
||
| 42 | ->set_content_type('application/json') |
||
| 43 | ->set_output(json_encode($json)); |
||
| 44 | } else { |
||
| 45 | $this->output->set_status_header('429', 'Rate limit reached.'); |
||
| 46 | } |
||
| 47 | } else { |
||
| 48 | $this->output->set_status_header('400', 'Not logged in.'); |
||
| 49 | } |
||
| 50 | } |
||
| 51 | } |
||
| 52 |