public function loggedIn() { $req = $this->app->request(); foreach (User::showUserByEmail($req->post('email')) as $row) { $stored_email = $row['u_email']; $stored_user_id = $row['user_id']; $stored_level = $row['level']; $stored_password = $row['u_password']; } if (User::countUser($req->post('email'))->fetchColumn() == 1 && Bcrypt::check($req->post('password'), $stored_password) === true) { $_SESSION['emailAdmin'] = $stored_email; $_SESSION['idAdmin'] = $stored_user_id; $_SESSION['levelAdmin'] = $stored_level; parent::redirectTo('indexAdmin'); } else { $this->app->flash('error', "Email or Password doesn't match"); $this->app->flash('tmpEmail', $req->post('email')); parent::redirectTo('loginAdmin'); } }
public function flashAny($init, $id = null) { $req = $this->app->request(); self::$errors = array(); $idData = explode('/', $_SERVER['REQUEST_URI']); $idAny = end($idData); if (filter_var($idAny, FILTER_VALIDATE_INT) === false) { if (User::countUser($req->post('email'))->fetchColumn() == 1) { self::$errors[] = 'Email sudah terdaftar'; } } if (count(self::$errors) > 0) { $this->app->flash('errors', self::$errors); $this->app->flash('tmpEmail', self::$tmpEmail); if ($init == 'add') { parent::redirectTo('addUser'); } else { self::$url = $this->app->urlFor('editUser', array('id' => $id)); $this->app->redirect(self::$url); } } }