Skip to content

Commit

Permalink
Corregido bug cuando el usuario no tiene permiso para ver una página.
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoRazorX committed Aug 4, 2022
1 parent 898a429 commit fb7cd34
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Core/Base/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Controller implements ControllerInterface
/**
* Name of the file for the template.
*
* @var string|false nombre_archivo.html.twig
* @var string nombre_archivo.html.twig
*/
private $template;

Expand Down Expand Up @@ -168,9 +168,9 @@ public function getPageData()
/**
* Return the template to use for this controller.
*
* @return string|false
* @return string
*/
public function getTemplate()
public function getTemplate(): string
{
return $this->template;
}
Expand Down Expand Up @@ -290,6 +290,14 @@ public function run(): void
$menuManager->selectPage($this->getPageData());

$permissions = new ControllerPermissions($user, $this->getClassName());
if (false === $permissions->allowAccess) {
echo Html::render('Error/AccessDenied.html.twig', [
'fsc' => $this,
'menuManager' => $menuManager
]);
return;
}

$this->privateCore($response, $user, $permissions);
if ($this->template) {
$response->setContent(
Expand All @@ -311,7 +319,7 @@ public function run(): void
*/
public function setTemplate($template): bool
{
$this->template = ($template === false) ? false : $template . '.html.twig';
$this->template = $template ? $template . '.html.twig' : '';
return true;
}

Expand Down

0 comments on commit fb7cd34

Please sign in to comment.