Logout::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 11
loc 11
rs 9.9
c 0
b 0
f 0
ccs 8
cts 8
cp 1
crap 1
1
<?php defined('BASEPATH') OR exit('No direct script access allowed');
2
3
class Logout extends User_Controller {
4
	//we shouldn't care if the user is logged in or not, since ion_auth will take care of things
5
6 1 View Code Duplication
	public function __construct() {
7 1
		parent::__construct();
8
9 1
		$this->load->helper('cookie');
10
11 1
		$this->load->library('form_validation');
12 1
		$this->form_validation->set_error_delimiters(
13 1
			$this->config->item('error_start_delimiter', 'ion_auth'),
14 1
			$this->config->item('error_end_delimiter', 'ion_auth')
15
		);
16 1
	}
17
18 1
	public function index() : void {
19 1
		$this->header_data['title'] = 'Logout';
20 1
		$this->header_data['page']  = 'logout';
21
22 1
		if($this->ion_auth->logged_in()) {
23
			//This is called again due to logout not always logging out properly. - https://github.com/benedmunds/CodeIgniter-Ion-Auth/issues/1191#issuecomment-378934024
24
			$this->ion_auth->logout() && $this->ion_auth->logout();
25
		}
26 1
		$this->session->set_flashdata('notices', 'Logout Successful');
27
28 1
		delete_cookie('remember_time');
29
30 1
		redirect('/', 'refresh'); //TODO: Should we have a custom logout page?
31
	} //@codeCoverageIgnore
32
}
33