Completed
Push — master ( 4a1c4b...dec28d )
by Angus
03:08
created

Logout::index()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3.0175

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 0
dl 0
loc 14
ccs 7
cts 8
cp 0.875
crap 3.0175
rs 9.7998
c 0
b 0
f 0
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