public function contact()
 {
     $this->session->csrf = uniqid();
     $brandsCategories = ShopData::getInstance()->loadCategories();
     $data = ['isLogged' => $this->isLoggedIn(), 'brandsCategories' => $brandsCategories];
     $this->view->appendToLayout('main', 'contact');
     $this->view->display('Layouts.default', $data);
 }
 public function buy()
 {
     if ($this->input->get()[1] !== $this->session->csrf) {
         throw new \Exception('Token invalid');
     }
     $productId = $this->input->get()[0];
     $userId = $this->session->userid;
     $success = ShopData::getInstance()->buyProduct($userId, $productId);
     if ($success) {
         header('Location: /');
         $this->session->csrf = uniqid();
     } else {
         throw new \Exception('Cannot buy product');
     }
 }
 public function profile()
 {
     if (!$this->isLoggedIn()) {
         header('Location: \\users\\login');
         $this->session->csrf = uniqid();
         exit;
     }
     $this->session->csrf = uniqid();
     $viewModel = $this->data->getInfo($this->session->userid);
     $viewModel->setCsrfToken($this->session->csrf);
     $brandsCategories = ShopData::getInstance()->loadCategories();
     $viewModel->setNavbarData('brands', $brandsCategories['brands']);
     $viewModel->setNavbarData('categories', $brandsCategories['categories']);
     $this->view->appendToLayout('main', 'profile');
     $this->view->display('profile', $viewModel);
 }