Code Duplication    Length = 16-16 lines in 2 locations

application/controllers/Ajax/GetKey.php 2 locations

@@ 18-33 (lines=16) @@
15
	 * METHOD:     POST
16
	 * URL:        /ajax/get_apikey
17
	 */
18
	public function index() : void {
19
		if($this->ion_auth->logged_in()) {
20
			if(!$this->limiter->limit('new_api_key', 10)) {
21
				$api_key = $this->User->get_new_api_key();
22
				$json    = ['api-key' => $api_key];
23
24
				$this->output
25
					->set_content_type('application/json')
26
					->set_output(json_encode($json));
27
			} else {
28
				$this->output->set_status_header('429', 'Rate limit reached.');
29
			}
30
		} else {
31
			$this->output->set_status_header('400', 'Not logged in.');
32
		}
33
	}
34
35
	public function restore() : void {
36
		if($this->ion_auth->logged_in()) {
@@ 35-50 (lines=16) @@
32
		}
33
	}
34
35
	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