Only administrator can make changes to categories
This commit is contained in:
@@ -81,11 +81,11 @@ class Posts
|
||||
|
||||
$url = 'Data/pengumuman.html';
|
||||
|
||||
$status = '';
|
||||
$privilage = '';
|
||||
|
||||
if (Session::exists('userid')) {
|
||||
$post = $this->model->showAll();
|
||||
$status = 'admin';
|
||||
$privilage = Session::get('privilage');
|
||||
}
|
||||
|
||||
if ($post !== false) {
|
||||
@@ -102,7 +102,7 @@ class Posts
|
||||
}
|
||||
View::render($url, [
|
||||
'posts' => $posts,
|
||||
'status' => $status
|
||||
'privilage' => $privilage
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -198,6 +198,11 @@ class Posts
|
||||
public function category()
|
||||
{
|
||||
if (Session::exists('userid')) {
|
||||
if (Session::get('privilage') != 1) {
|
||||
Session::flash('info', 'Hanya admin yang bisa mengatur kategori.');
|
||||
Redirect::to('/');
|
||||
die();
|
||||
}
|
||||
$categories = [];
|
||||
$get_categories = $this->model->showAll([], 'kategori');
|
||||
|
||||
@@ -212,7 +217,7 @@ class Posts
|
||||
'token' => Token::generate()
|
||||
]);
|
||||
} else {
|
||||
throw new \Exception("Bad request", 400);
|
||||
throw new \Exception("Page not found", 404);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user