public function index() { $auth = new Auth(); $user = $auth->getUserSession(); if ($user->level == 1) { $this->slim->redirect($this->slim->request()->getRootUri() . '/user'); } $this->slim->redirect($this->slim->request()->getRootUri() . '/employer'); }
public function post_edit($id) { $attr = $this->slim->request->post(); $attr['id'] = $id; $auth = new Auth(); $form = new EmployeeForm($attr); $userlogin = $auth->getUserSession(); if ($form->validate()) { $form->save($userlogin->id); $this->slim->redirect($this->slim->request()->getRootUri() . '/employee'); } else { $this->slim->render("employee/add.php", ['form' => $form]); } }
public function validate() { $attr = $this->attr; if (empty($attr['username'])) { $this->pushError("กรุณาใส่ username"); return false; } if (empty($attr['password'])) { $this->pushError("กรุณาใส่ password"); return false; } $auth = new Auth(); $user = $auth->auth($attr['username'], $attr['password']); if (!$user) { $this->pushError($auth->getError()); return false; } $this->user = $user; return true; }
public function index() { $auth = new Auth(); $user = $auth->getUserSession(); $this->slim->redirect($this->slim->request()->getRootUri() . '/news'); }