Added error handler
This commit is contained in:
@@ -24,6 +24,7 @@ class Home
|
||||
public function login()
|
||||
{
|
||||
if (Session::exists('userid')) {
|
||||
Session::flash('info', 'You already logged in');
|
||||
Redirect::to('/');
|
||||
} else {
|
||||
View::render('Access/login.html', [
|
||||
@@ -39,7 +40,7 @@ class Home
|
||||
'token' => Token::generate()
|
||||
]);
|
||||
} else {
|
||||
Redirect::to('/');
|
||||
throw new \Exception("Bad Request", 400);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class Posts
|
||||
['valid_at', '<=', $now],
|
||||
['status', '!=', 3]
|
||||
]);
|
||||
if ($valid !== false) {
|
||||
if ($valid) {
|
||||
foreach ($valid as $fields) {
|
||||
$id = $fields['id'];
|
||||
|
||||
@@ -42,7 +42,7 @@ class Posts
|
||||
['valid_at', '>', $now],
|
||||
['status', '!=', 3]
|
||||
]);
|
||||
if ($not_valid !== false) {
|
||||
if ($not_valid) {
|
||||
foreach ($not_valid as $fields) {
|
||||
$id = $fields['id'];
|
||||
|
||||
@@ -54,7 +54,7 @@ class Posts
|
||||
['expired_at', '<', $now],
|
||||
['status', '!=', 3]
|
||||
]);
|
||||
if ($expired !== false) {
|
||||
if ($expired) {
|
||||
foreach ($expired as $fields) {
|
||||
$id = $fields['id'];
|
||||
|
||||
@@ -108,7 +108,7 @@ class Posts
|
||||
'token' => Token::generate()
|
||||
]);
|
||||
} else {
|
||||
Redirect::to('/');
|
||||
throw new \Exception("Page not found", 404);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ class Posts
|
||||
);
|
||||
}
|
||||
} else {
|
||||
Redirect::to('/');
|
||||
throw new \Exception("Page not found", 404);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ class Posts
|
||||
'token' => Token::generate()
|
||||
]);
|
||||
} else {
|
||||
Redirect::to('/');
|
||||
throw new \Exception("Page not found", 404);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user