57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
<?php
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
/*
|
|
MERM Providers Login
|
|
*/
|
|
class Login extends Web_Controller {
|
|
|
|
public function index() {
|
|
|
|
$data = array();
|
|
$data['username'] = $data['pass'] = $data['error_message']='';
|
|
|
|
if ($_POST) {
|
|
|
|
$data['username'] = trim($this->input->post('username'));
|
|
$data['pass'] = htmlspecialchars($this->input->post('pass'));
|
|
$outData = array();
|
|
$loginResult = $this->verifyLoginInput($data); // initial test
|
|
if ($loginResult == true) {
|
|
|
|
$loginResult = false; // reset again for real login
|
|
$loginResult = $this->loginUser($data, $outData);
|
|
if (true == $loginResult) {
|
|
$out = array();
|
|
redirect('provider'); // provider controller extend Provider_Controller- this check session valid
|
|
}
|
|
}// if valid input was supplied
|
|
else
|
|
{
|
|
$data['error_message']="Invalid Username or Password";
|
|
}
|
|
|
|
if (false == $loginResult) {
|
|
$this->renderExternalPage('welcome_message', $data); // get here if login galis
|
|
}
|
|
} else {
|
|
$this->renderExternalPage('welcome_message', $data);
|
|
}
|
|
} // end of index Login
|
|
|
|
private function verifyLoginInput(&$data) {
|
|
|
|
$ret = false;
|
|
if ($data['username'] == '' or $data['pass'] == '') {
|
|
$data['error_message']="Username and password required";
|
|
}
|
|
|
|
if (trim($data['username']) != '' or trim($data['pass']) != '') {
|
|
$ret = true;
|
|
}
|
|
|
|
return $ret;
|
|
}
|
|
|
|
}
|