access = new Access(); } public function index() { $posts = new Posts(); $posts->index(); } public function login() { if (Session::exists('userid')) { Redirect::to('/'); } else { View::render('Access/login.html', [ 'token' => Token::generate() ]); } } public function register() { if (Session::exists('userid')) { if (Session::get('privilage') == 1) { View::render('Access/registrasi.html', [ 'token' => Token::generate() ]); } } else { Session::flash('info', Session::get('privilage')); Redirect::to('/'); } } // Methods public function post($args = []) { $table = 'user'; $date = new \DateTime(); $now = $date->format('Y-m-d'); $args['registered_at'] = $now; $salt = Hash::salt(); $password = Hash::make($args['password'], $salt); $args['salt'] = $salt; $args['password'] = $password; $args['full_name'] = htmlspecialchars($args['full_name']); $args['username'] = htmlspecialchars($args['username']); $this->access->entry($table, $args); // Redirect::to('/'); } public function put($args = []) { if ($this->access->login($args)) { $table = 'user'; $id = Session::get('userid'); $this->access->update($table, ['status' => 1], $id); } Redirect::to('/'); } public function logout() { if ($this->access->logout()) { Redirect::to('/'); } } }