59 lines
1.8 KiB
PHP
59 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
/*
|
|
MERM Providers Login
|
|
*/
|
|
class Login extends BaseController {
|
|
|
|
protected \App\Models\Auth_model $auth_model;
|
|
public function __construct() {
|
|
// parent::__construct();
|
|
$this->auth_model = new \App\Models\Auth_model();
|
|
}
|
|
public function HomeLogin(){
|
|
$data = array();
|
|
return $this->renderExternalPage('welcome_message', $data);
|
|
}
|
|
public function StartLogin() {
|
|
|
|
$data = array();
|
|
$data['username'] = $data['pass'] = $data['error_message']='';
|
|
//$this->request->getPost();
|
|
// Get input from form
|
|
$username = $this->request->getVar('username');
|
|
$password = $this->request->getVar('mermspassword');
|
|
log_message('critical', "***** ***** WrenchAuth::userLogin USER_SESSION = ".$username );
|
|
if ($username != '' && $password !=''){
|
|
log_message('critical', "***** ***** WrenchAuth::userLogin USER_SESSION = ".$username );
|
|
$out = $this->auth_model->userLogin($username, $password);
|
|
// var_dump($out);
|
|
// exit;
|
|
if ($this->createUserSession($out)){ // session was built
|
|
return redirect()->to('providers');
|
|
}
|
|
}
|
|
$data = array();
|
|
return $this->renderExternalPage('welcome_message', $data);
|
|
} // end of index Login
|
|
|
|
public function RegisterAccount(){
|
|
$data = array();
|
|
return $this->renderExternalPage('register', $data);
|
|
}
|
|
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;
|
|
}
|
|
|
|
}
|