<?php
namespace App\Controller;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class WelcomeController extends AbstractController
{
/**
* @Route("/",name="app_welcome", methods={"GET"})
*/
public function welcome(AuthenticationUtils $authenticationUtils)
{
$securityContext = $this->container->get('security.authorization_checker');
if ($securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
if($securityContext->isGranted('ROLE_CLIENT')){
return $this->redirectToRoute('client_user_hub');
}else {
return $this->redirectToRoute('app_admin_index');
}
}
return $this->redirect('/it/admin/login');
}
/**
* @Route("/documents/{filename}", methods={"GET"})
*/
public function documents($filename,$documentsPath) {
$pathToFile = $documentsPath."/".$filename;
if(strpos($pathToFile,"..")!==false){
throw $this->createNotFoundException();
}
if(file_exists($pathToFile)){
return new BinaryFileResponse($pathToFile);
}
throw $this->createNotFoundException();
}
}