You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

52 lines
1.4 KiB

<?php
namespace App\Controllers;
use CodeIgniter\Controller;
use App\Models\Mauth;
class Auth extends Controller
{
public function index()
{
helper(['form']);
echo view('pages/loginv');
}
public function login()
{
$session = session();
$model = new Mauth();
$uname = $this->request->getVar('username');
$password = $this->request->getVar('password');
$param = array('name' => $uname, 'passwd' => $password);
$data = $model->cekuser($param)->getRowArray();
// var_dump($data);
//exit();
if ($data) {
$ses_data = [
'nip' => $data['NIP9'],
'nama' => $data['NAMA'],
'kppadm' => $data['KPPADM'],
'jabatan' => $data['NAMA_JABATAN'],
'kantor' => $data['NAMA_KANTOR'],
'seksi' => $data['NAMA_UNIT_ES3']
];
$session->set($ses_data);
return redirect()->to(base_url('Home'));
} else {
//print_r('user tidak ada');
//exit;
$session->setFlashdata('msg', 'User Tidak ada');
return redirect()->to('auth');
}
}
public function logout()
{
$session = session();
$session->destroy();
return redirect()->to('auth');
}
}