Added condition when login invalid

This commit is contained in:
Gregorio Chiko Putra 2017-09-06 10:57:17 +07:00
parent 71fb5e4933
commit a34ce9d0eb
2 changed files with 6 additions and 6 deletions

View File

@ -16,7 +16,6 @@ class Home
} }
public function index() 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 = new Posts();
$posts->index(); $posts->index();
return true; return true;
@ -24,23 +23,23 @@ class Home
public function login() 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', [ View::render('Access/login.html', [
'token' => Token::generate() 'token' => Token::generate()
]); ]);
return true; return true;
} }
// Methods
public function put($args = []) public function put($args = [])
{ {
if ($this->access->login($args)) { if ($this->access->login($args)) {
$table = 'user'; $table = 'user';
$id = Session::get('userid'); $id = Session::get('userid');
if ($this->access->update($table, ['status' => 1], $id)) {
$this->access->update($table, ['status' => 1], $id);
}
Redirect::to('/'); Redirect::to('/');
} }
}
}
public function logout() public function logout()
{ {

View File

@ -14,7 +14,7 @@ class Access extends \Core\Model
'salt char(23) NOT NULL', 'salt char(23) NOT NULL',
'name varchar(50) NOT NULL', 'name varchar(50) NOT NULL',
'registered_at date NOT NULL DEFAULT CURRENT_TIMESTAMP', 'registered_at date NOT NULL DEFAULT CURRENT_TIMESTAMP',
'status tinyint NOT NULL DEFAULT 1', 'status tinyint NOT NULL DEFAULT 0',
'PRIMARY KEY (id)' 'PRIMARY KEY (id)'
] ]
); );
@ -94,6 +94,7 @@ class Access extends \Core\Model
} }
} }
} }
\Core\Session::flash('info', 'Invalid username/password');
return false; return false;
} catch (PDOException $e) { } catch (PDOException $e) {
echo $e->getMessage(); echo $e->getMessage();