I want the whole site to be protected through login with FOSUserBundle. I tried installing security.yml like this
security: encoders: Symfony\Component\Security\Core\User\User: plaintext FOS\UserBundle\Model\UserInterface: sha512 role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] providers: fos_userbundle: id: fos_user.user_manager firewalls: main: pattern: ^/ form_login: check_path: /login_check login_path: /login provider: fos_userbundle always_use_default_target_path: true default_target_path: /dashboard logout: path: /logout target: / anonymous: ~
But then I do not know what to install in config.yml this is my config.yml
imports: - { resource: parameters.yml } - { resource: security.yml } framework:
and this is my controller
<?php namespace Proposals\ProposalsBundle\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Proposals\ProposalsBundle\Entity\Proposals; use Proposals\ProposalsBundle\Form\ProposalsType; class ProposalsController extends Controller { public function indexAction() { $em = $this->getDoctrine()->getManager(); $entities = $em->getRepository('ProposalsProposalsBundle:Proposals')->findAll(); return $this->render('ProposalsProposalsBundle:Proposals:index.html.twig', array( 'entities' => $entities, )); }
When I open any page, you do not check whether the user is registered or not. I want each page to be protected by logging in if the user is logged in, then each page is opened if the user is not logged in, and then the page is not displayed or redirected to login.any help appriciated
user2696178
source share