Beispiel #1
0
 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');
 }
Beispiel #2
0
 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]);
     }
 }
Beispiel #3
0
 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;
 }
Beispiel #4
0
 public function index()
 {
     $auth = new Auth();
     $user = $auth->getUserSession();
     $this->slim->redirect($this->slim->request()->getRootUri() . '/news');
 }