- <?php
- namespace App\Auth;
- use App\Entity\Person;
- use App\Entity\User;
- use App\Form\LoginForm;
- use App\Handlers\SMSSenderHandler;
- use App\Messages\SMSMessage;
- use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
- use Symfony\Component\HttpFoundation\Request;
- use Symfony\Component\HttpFoundation\Response;
- use Symfony\Component\Messenger\MessageBusInterface;
- use Symfony\Component\Routing\Annotation\Route;
- use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
- class LoginController extends AbstractController
- {
-     /**
-      * @Route("/sign_in", name="security_signin")
-      * @param AuthenticationUtils $authenticationUtils
-      * @return Response
-      */
-     public function loginAction(AuthenticationUtils $authenticationUtils): Response
-     {
-         // if ($this->getUser()) {
-         //     return $this->redirectToRoute('target_path');
-         // }
-         // get the login error if there is one
-         $error = $authenticationUtils->getLastAuthenticationError();
-         // last username entered by the user
-         $lastUsername = $authenticationUtils->getLastUsername();
-         return $this->render('security/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]);
-     }
-     /**
-      * @Route("/logout", name="logout")
-      */
-     public function logoutAction(){
- //        throw new \Exception("Something went terribly Wrong",Response::HTTP_INTERNAL_SERVER_ERROR, null);
-     }
-     /**
-      * @Route("/end", name="no_mans_land")
-      */
-     public function endLand() {
- //        throw new \Exception("Something went terribly Wrong",Response::HTTP_INTERNAL_SERVER_ERROR, null);
-         return $this->render('registration/no_mans_land.html.twig',[]);
-     }
-     /**
-      * @Route("/sign_in/queue_sms", name="queue")
-      */
-     public function queueSMS(MessageBusInterface $messageBus): Response
-     {
-         $messageBus->dispatch(new SMSMessage(523142));
-         return new Response('awesome');
-     }
-     /**
-      * @Route("/user")
-      */
-     public function insertAction(){
-         $user = new User();
-         $person = new Person();
-         $person->setFirstName('Hilary');
-         $person->setSecondName('Njiru');
-         $person->setSirName('Ngari');
-         $person->setCreatedAt(new \DateTime());
-         $person->setCreatedBy(null);
-         $person->setNationalId("9090903");
-         $person->setDateOfBirth(new \DateTime("1980-01-01"));
-         $person->setGender("Male");
-         $person->setPhoneNumber("0728167911");
-         $user->setRoles(['ROLE_USER']);
-         $user->setUsername('hilary');
-         $user->setPlainPassword('mirage');
-         $user->setCreatedAt(new \DateTime());
-         $user->setPerson($person);
-         $user->setEmail('hilary.nn@gmail.com');
-         $em  = $this->getDoctrine()->getManager();
-         $em->persist($person);
-         $em->persist($user);
-         $em->flush();
-     }
-     /**
-      * @Route("/user2")
-      */
-     public function insert2Action(){
-         $user = new User();
-         $person = new Person();
-         $person->setFirstName('Samuel');
-         $person->setSecondName('Muturi');
-         $person->setSirName('Njuguna');
-         $person->setCreatedAt(new \DateTime());
-         $person->setCreatedBy(null);
-         $person->setNationalId("27787431");
-         $person->setDateOfBirth(new \DateTime("1990-01-01"));
-         $person->setGender("Male");
-         $person->setPhoneNumber("0716308459");
-         $user->setRoles(['ROLE_USER']);
-         $user->setUsername('samuel');
-         $user->setPlainPassword('mirage');
-         $user->setCreatedAt(new \DateTime());
-         $user->setPerson($person);
-         $user->setEmail('samnjuguna07@@gmail.com');
-         $em  = $this->getDoctrine()->getManager();
-         $em->persist($person);
-         $em->persist($user);
-         $em->flush();
-     }
- }