From a34ce9d0eb8269bfde8d80e33f30a27f233421f1 Mon Sep 17 00:00:00 2001 From: Gregorio Chiko Putra Date: Wed, 6 Sep 2017 10:57:17 +0700 Subject: [PATCH] Added condition when login invalid --- App/Controllers/Home.php | 9 ++++----- App/Models/Access.php | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/App/Controllers/Home.php b/App/Controllers/Home.php index 66e6050..6895903 100644 --- a/App/Controllers/Home.php +++ b/App/Controllers/Home.php @@ -16,7 +16,6 @@ class Home } public function index() { - // echo "This is index of home"; // Nanti di replace sama twig view ke App\Views\Data\pengumuman.html $posts = new Posts(); $posts->index(); return true; @@ -24,22 +23,22 @@ class Home public function login() { - // echo "You have to login"; // Nanti di replace sama twig view ke App\Views\Access\login.html View::render('Access/login.html', [ 'token' => Token::generate() ]); return true; } + // Methods public function put($args = []) { if ($this->access->login($args)) { $table = 'user'; $id = Session::get('userid'); - if ($this->access->update($table, ['status' => 1], $id)) { - Redirect::to('/'); - } + + $this->access->update($table, ['status' => 1], $id); } + Redirect::to('/'); } public function logout() diff --git a/App/Models/Access.php b/App/Models/Access.php index 59f649d..201c2e1 100644 --- a/App/Models/Access.php +++ b/App/Models/Access.php @@ -14,7 +14,7 @@ class Access extends \Core\Model 'salt char(23) NOT NULL', 'name varchar(50) NOT NULL', 'registered_at date NOT NULL DEFAULT CURRENT_TIMESTAMP', - 'status tinyint NOT NULL DEFAULT 1', + 'status tinyint NOT NULL DEFAULT 0', 'PRIMARY KEY (id)' ] ); @@ -94,6 +94,7 @@ class Access extends \Core\Model } } } + \Core\Session::flash('info', 'Invalid username/password'); return false; } catch (PDOException $e) { echo $e->getMessage();