|
|
@ -13,6 +13,31 @@ class Login extends CI_Controller |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function index() |
|
|
|
public function index() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// redirect if session exists |
|
|
|
|
|
|
|
$this->load->library('session'); |
|
|
|
|
|
|
|
if(! $this->session->userdata('validated')){ |
|
|
|
|
|
|
|
redirect('/dashboard'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->form_validation->set_rules('username', 'Username', 'required'); |
|
|
|
|
|
|
|
$this->form_validation->set_rules('password', 'Password', 'required'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (! ($this->input->post('username') AND $this->input->post('password'))) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$this->_showlogin(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
elseif ($this->form_validation->run() == FALSE) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$this->_showlogin('No username or password.'); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// check login |
|
|
|
|
|
|
|
$this->_checklogin(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function _showlogin($errormsg = NULL) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Load model |
|
|
|
// Load model |
|
|
|
$this->load->model('Regio_model'); |
|
|
|
$this->load->model('Regio_model'); |
|
|
@ -23,20 +48,16 @@ class Login extends CI_Controller |
|
|
|
$data['regio'][$regio['id']] = $regio['naam']; |
|
|
|
$data['regio'][$regio['id']] = $regio['naam']; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($errormsg) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$data['errormsg'] = $errormsg; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Header |
|
|
|
// Header |
|
|
|
$this->load->view('header'); |
|
|
|
$this->load->view('header'); |
|
|
|
|
|
|
|
|
|
|
|
$this->form_validation->set_rules('username', 'Username', 'required'); |
|
|
|
// login page |
|
|
|
$this->form_validation->set_rules('password', 'Password', 'required'); |
|
|
|
$this->load->view('login', $data); |
|
|
|
|
|
|
|
|
|
|
|
if ($this->form_validation->run() == FALSE) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// login page |
|
|
|
|
|
|
|
$this->load->view('login', $data); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// check login |
|
|
|
|
|
|
|
$this->_checklogin(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Footer |
|
|
|
// Footer |
|
|
|
$this->load->view('footer'); |
|
|
|
$this->load->view('footer'); |
|
|
@ -46,15 +67,25 @@ class Login extends CI_Controller |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Load model |
|
|
|
// Load model |
|
|
|
$this->load->model('Login_model'); |
|
|
|
$this->load->model('Login_model'); |
|
|
|
$logincheck = $this->Login_model->check_user(); |
|
|
|
$userdata = $this->Login_model->check_user(); |
|
|
|
|
|
|
|
|
|
|
|
if ($logincheck == FALSE) { |
|
|
|
if ($userdata == FALSE) { |
|
|
|
echo "No user "; |
|
|
|
$this->_showlogin('Wrong username or password'); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
echo "Ok"; |
|
|
|
$this->_startsession($userdata); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function _startsession($userdata) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Start session with user data |
|
|
|
|
|
|
|
$this->load->library('session'); |
|
|
|
|
|
|
|
$this->session->set_userdata($userdata); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Redirect to dashboard |
|
|
|
|
|
|
|
redirect('/dashboard'); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
?> |
|
|
|
?> |