Added condition when login invalid
This commit is contained in:
parent
71fb5e4933
commit
a34ce9d0eb
@ -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,22 +23,22 @@ 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)) {
|
|
||||||
Redirect::to('/');
|
$this->access->update($table, ['status' => 1], $id);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Redirect::to('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function logout()
|
public function logout()
|
||||||
|
@ -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();
|
||||||
|
Loading…
Reference in New Issue
Block a user