Skip to content
Snippets Groups Projects
Commit 9c2e6690 authored by Alexander Jason's avatar Alexander Jason
Browse files

feat: add controller to authorize check collection

parent 1ec007b0
No related merge requests found
......@@ -10,16 +10,50 @@ class PremiumController extends Controller implements ControllerInterface
// TODO: PARAMS ROUTING
public function index()
{
if (!isset($_SESSION['username'])) {
http_response_code(301);
header("Location: /user/login", true, 301);
exit;
}
$premiumView = $this->view('premium', 'PremiumView');
$premiumView->render();
}
public function detail()
{
$premiumView = $this->view('premium', 'CollectionDetailView');
$premiumView->render();
public function detail($params = null){
if (!isset($_SESSION['username'])) {
http_response_code(301);
header("Location: /user/login", true, 301);
exit;
}
try {
switch ($_SERVER['REQUEST_METHOD']) {
case 'GET':
$collectionId = (int)$params;
// User
if(isset($_SESSION['username'])){
$userData = $this->model('UserModel');
$user = $userData->getUserByUsername($_SESSION['username']);
$username = $user['username'];
$nav = ['username'=>$username];
}else{
$nav = ['username'=>null];
}
$premiumView = $this->view('premium', 'CollectionDetailView', array_merge($nav, ['collectionId'=>$collectionId]));
$premiumView->render();
break;
default:
throw new RequestException('Method Not Allowed', 405);
}
} catch (Exception $e) {
http_response_code($e->getCode());
exit;
}
}
public function book()
{
public function book($params=null){
if (!isset($_SESSION['username'])) {
http_response_code(301);
header("Location: /user/login", true, 301);
exit;
}
$premiumView = $this->view('premium', 'PremiumBookDetailView');
$premiumView->render();
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment