<commit_before><?php

namespace GuideBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use GuideBundle\Entity\Auth;
use GuideBundle\Entity\Actors;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;

class SecurityController extends Controller
{
    /**
     * @Route("/auth", name="auth")
     */
    public function loginAction(Request $request)
    {
        $user = new Auth();
        //$form = $this->createForm(AuthType::class, $user);
        $form = $this->createFormBuilder($user)
            ->add('username', TextType::class)
            ->add('password', PasswordType::class)
            ->add('Log in', SubmitType::class, array('label' => '�����'))
            ->getForm();

        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $user = $this
                ->getDoctrine()
                ->getRepository("GuideBundle:Auth")
                ->findOneBy(
                    array(
                        "username" => $user->getUsername(),
                        "password" => $<PASSWORD>-><PASSWORD>())
                );
            if ($user) {
                $role = $this
                    ->getDoctrine()
                    ->getRepository("GuideBundle:Actors")
                    ->findOneBy(
                        array(
                            "id" => $user->getId()
                        )
                    );
                if ($role === 5) {
                    $userInfo = $this
                        ->getDoctrine()
                        ->getRepository("GuideBundle:RegInfo")
                        ->findOneBy(
                            array(
                                "actorId" => $user->getId()
                            )
                        );
                } else {
                    $userInfo = $this
                        ->getDoctrine()
                        ->getRepository("GuideBundle:MedicalStaff")
                        ->findOneBy(
                            array(
                                "actorId" => $user->getId()
                            )
                        );
                }


                $session = $request->getSession();
                $session->remove('user');
                $session->clear();

                if ($role->getRole() == 1) {
                    $session->set('user', array(
                        'role' => $role->getRole()
                    ));
                } else {
                    $session->set('user', array(
                        'role' => $role->getRole(),
                        'username' => $user->getUsername(),
                        'first_name' => $userInfo->getFirstName(),
                        'last_name' => $userInfo->getLastName(),
                        'patronymic' => $userInfo->getPatronymic()
                    ));
                }
                var_dump($session->get('user'));
//                switch ($role) {
//                    case '1':
//                        return $this->redirectToRoute('admin/cab');
//                    case '2':
//                        return $this->redirectToRoute('doc/cab');
//                    case '3':
//                        return $this->redirectToRoute('lab/cab');
//                    case '4':
//                        return $this->redirectToRoute('reception/cab');
//                    case '5':
//                        return $this->redirectToRoute('pat/cab');
//                }

            }
            
        }


        /*if ($form->isValid()) {
            $user = $this->getDoctrine()
                ->getRepository('GuideBundle:Auth')
                ->findOneBy(
                    array(
                        'username' => $loginForm->getUsername(),
                        'password' => $<PASSWORD>()
                    )
                );
        }

        if ($user) echo "loh";*/

        return $this->render('auth/auth.html.twig', array(
            'form' => $form->createView(),
        ));
    }


}<commit_msg>Error when user is not found added<commit_after><?php

namespace GuideBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use GuideBundle\Entity\Auth;
use GuideBundle\Entity\Actors;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;

class SecurityController extends Controller
{
    /**
     * @Route("/auth", name="auth")
     */
    public function loginAction(Request $request)
    {
        $error = '';
        $user = new Auth();
        //$form = $this->createForm(AuthType::class, $user);
        $form = $this->createFormBuilder($user)
            ->add('username', TextType::class)
            ->add('password', PasswordType::class)
            ->add('Log in', SubmitType::class, array('label' => '�����'))
            ->getForm();

        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $user = $this
                ->getDoctrine()
                ->getRepository("GuideBundle:Auth")
                ->findOneBy(
                    array(
                        "username" => $user->getUsername(),
                        "password" => $user->getPassword())
                );
            if ($user) {
                $role = $this
                    ->getDoctrine()
                    ->getRepository("GuideBundle:Actors")
                    ->findOneBy(
                        array(
                            "id" => $user->getId()
                        )
                    );
                if ($role === 5) {
                    $userInfo = $this
                        ->getDoctrine()
                        ->getRepository("GuideBundle:RegInfo")
                        ->findOneBy(
                            array(
                                "actorId" => $user->getId()
                            )
                        );
                } else {
                    $userInfo = $this
                        ->getDoctrine()
                        ->getRepository("GuideBundle:MedicalStaff")
                        ->findOneBy(
                            array(
                                "actorId" => $user->getId()
                            )
                        );
                }


                $session = $request->getSession();
                $session->remove('user');
                $session->clear();

                if ($role->getRole() == 1) {
                    $session->set('user', array(
                        'role' => $role->getRole()
                    ));
                } else {
                    $session->set('user', array(
                        'role' => $role->getRole(),
                        'username' => $user->getUsername(),
                        'first_name' => $userInfo->getFirstName(),
                        'last_name' => $userInfo->getLastName(),
                        'patronymic' => $userInfo->getPatronymic()
                    ));
                }
                var_dump($session->get('user'));
//                switch ($role) {
//                    case '1':
//                        return $this->redirectToRoute('admin/cab');
//                    case '2':
//                        return $this->redirectToRoute('doc/cab');
//                    case '3':
//                        return $this->redirectToRoute('lab/cab');
//                    case '4':
//                        return $this->redirectToRoute('reception/cab');
//                    case '5':
//                        return $this->redirectToRoute('pat/cab');
//                }

            } else {
                $error = "* ERROR";
            }
            
        }


        /*if ($form->isValid()) {
            $user = $this->getDoctrine()
                ->getRepository('GuideBundle:Auth')
                ->findOneBy(
                    array(
                        'username' => $loginForm->getUsername(),
                        'password' => $<PASSWORD>()
                    )
                );
        }

        if ($user) echo "loh";*/

        return $this->render('auth/auth.html.twig', array(
            'form' => $form->createView(), 'error' => $error
        ));
    }


}
{'fraction_non_alphanumeric': 0.14101679319070623, 'fraction_numerical': 0.001610305958132045, 'mean_word_length': 1.068268315889629, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 138, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4620382', 'n_tokens_mistral': 2196, 'n_tokens_neox': 2022, 'n_words': 326}