<commit_before><?php

namespace Boilr\BoilrBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller,
    Symfony\Component\Security\Core\SecurityContext,
    Sensio\Bundle\FrameworkExtraBundle\Configuration\Route,
    Sensio\Bundle\FrameworkExtraBundle\Configuration\Template,
    JMS\SecurityExtraBundle\Annotation\Secure;

class DefaultController extends Controller
{
    /**
     * @Route("/", name="homepage")
     * @Template()
     */
    public function indexAction()
    {
        return array();
    }

    /**
     * @Route("/login", name="login")
     * @Template()
     */
    public function loginAction()
    {
        if ($this->get('request')->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
            $error = $this->get('request')->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
        } else {
            $error = $this->get('request')->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
        }

        return array(
            'last_username' => $this->get('request')->getSession()->get(SecurityContext::LAST_USERNAME),
            'error'         => $error);
    }

    /**
     * @Route("/admin", name="admin_homepage")
     * @Secure(roles="ROLE_ADMIN, ROLE_SUPERUSER")
     * @Template("BoilrBundle:Default:template5-admin.html.twig")
     */
    public function adminHomeAction()
    {
        return array();
    }
}<commit_msg>- aggiunte direttive di autorizzazione - aggiunto redirect per un login di un installatore<commit_after><?php

namespace Boilr\BoilrBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller,
    Symfony\Component\Security\Core\SecurityContext,
    Sensio\Bundle\FrameworkExtraBundle\Configuration\Route,
    Sensio\Bundle\FrameworkExtraBundle\Configuration\Template,
    JMS\SecurityExtraBundle\Annotation\Secure;
use Boilr\BoilrBundle\Entity\User as MyUser,
    Boilr\BoilrBundle\Entity\Group as MyGroup;

class DefaultController extends BaseController
{

    /**
     * @Route("/", name="homepage")
     * @Template()
     */
    public function indexAction()
    {
        $user = $this->getCurrentUser();
        if ($user->hasRole(MyGroup::ROLE_INSTALLER)) {
            return $this->redirect($this->generateUrl('installer_homepage'));
        }

        return array();
    }

    /**
     * @Route("/login", name="login")
     * @Template()
     */
    public function loginAction()
    {
        if ($this->get('request')->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
            $error = $this->get('request')->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
        } else {
            $error = $this->get('request')->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
        }

        return array(
            'last_username' => $this->get('request')->getSession()->get(SecurityContext::LAST_USERNAME),
            'error' => $error);
    }

    /**
     * @Route("/admin", name="admin_homepage")
     * @Secure(roles="ROLE_ADMIN, ROLE_SUPERUSER")
     * @Template("BoilrBundle:Default:template5-admin.html.twig")
     */
    public function adminHomeAction()
    {
        return array();
    }

    /**
     * @Route("/installer", name="installer_homepage")
     * @Secure(roles="ROLE_ADMIN, ROLE_SUPERUSER, ROLE_INSTALLER")
     * @Template("BoilrBundle:Default:template5-installer.html.twig")
     */
    public function installerHomeAction()
    {
        return array();
    }

}
{'fraction_non_alphanumeric': 0.14955163436505642, 'fraction_numerical': 0.0008678044547295343, 'mean_word_length': 3.1166666666666667, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1685477', 'n_tokens_mistral': 1019, 'n_tokens_neox': 1007, 'n_words': 136}