Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 5 |
CRAP Score | 4.4609 |
Changes | 0 |
1 | <?php defined('BASEPATH') or exit('No direct script access allowed'); |
||
18 | 1 | public function index() : void { |
|
19 | 1 | $this->form_validation->set_rules('username', 'Username', 'required|max_length[100]'); |
|
20 | |||
21 | 1 | if($this->form_validation->run() === TRUE) { |
|
22 | if(!$this->limiter->limit('username_check', 25)) { |
||
23 | $is_unique_username = $this->form_validation->is_unique_username($this->input->post('username')); |
||
24 | |||
25 | $data = [ |
||
26 | 'success' => $is_unique_username, |
||
27 | 'csrf_token' => $this->security->get_csrf_hash() //CHECK: Does returning this within the same query make the CSRF pointless? |
||
28 | ]; |
||
29 | $this->_render_json($data); |
||
30 | } else { |
||
31 | $this->output->set_status_header('429', 'Rate limit reached.'); //rate limited reached |
||
32 | } |
||
33 | } else { |
||
34 | 1 | $this->output->set_status_header('400', 'Missing/invalid parameters.'); |
|
35 | } |
||
36 | 1 | } |
|
37 | } |
||
38 |