namespace Rapsys\UserBundle\Controller;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
namespace Rapsys\UserBundle\Controller;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
if (!($user = $this->doctrine->getRepository($this->config['class']['user'])->findOneByMail($mail))) {
//Add error message mail already exists
//XXX: prevent slugger reverse engineering by not displaying decoded mail
if (!($user = $this->doctrine->getRepository($this->config['class']['user'])->findOneByMail($mail))) {
//Add error message mail already exists
//XXX: prevent slugger reverse engineering by not displaying decoded mail
//Redirect to register view
return $this->redirectToRoute($this->config['route']['register']['name'], $this->config['route']['register']['context']);
//Redirect to register view
return $this->redirectToRoute($this->config['route']['register']['name'], $this->config['route']['register']['context']);
if (empty($user = $this->doctrine->getRepository($this->config['class']['user'])->findOneByMail($mail))) {
//Throw not found
//XXX: prevent slugger reverse engineering by not displaying decoded mail
if (empty($user = $this->doctrine->getRepository($this->config['class']['user'])->findOneByMail($mail))) {
//Throw not found
//XXX: prevent slugger reverse engineering by not displaying decoded mail
}
//Prevent access when not admin, user is not guest and not currently logged user
if (!$this->checker->isGranted($this->config['default']['admin']) && $user != $this->security->getUser() || !$this->checker->isGranted('IS_AUTHENTICATED_FULLY')) {
//Throw access denied
//XXX: prevent slugger reverse engineering by not displaying decoded mail
}
//Prevent access when not admin, user is not guest and not currently logged user
if (!$this->checker->isGranted($this->config['default']['admin']) && $user != $this->security->getUser() || !$this->checker->isGranted('IS_AUTHENTICATED_FULLY')) {
//Throw access denied
//XXX: prevent slugger reverse engineering by not displaying decoded mail
//Set action to edit route name and context
'action' => $this->generateUrl($this->config['route']['edit']['name'], ['mail' => $smail, 'hash' => $this->slugger->hash($smail)]+$this->config['route']['edit']['context']),
//Set civility class
//Set action to edit route name and context
'action' => $this->generateUrl($this->config['route']['edit']['name'], ['mail' => $smail, 'hash' => $this->slugger->hash($smail)]+$this->config['route']['edit']['context']),
//Set civility class
//With admin role
if ($this->checker->isGranted($this->config['default']['admin'])) {
//Create the EditType form and give the proper parameters
//With admin role
if ($this->checker->isGranted($this->config['default']['admin'])) {
//Create the EditType form and give the proper parameters
//Set action to edit route name and context
'action' => $this->generateUrl($this->config['route']['edit']['name'], ['mail' => $smail, 'hash' => $this->slugger->hash($smail)]+$this->config['route']['edit']['context']),
//Set method
//Set action to edit route name and context
'action' => $this->generateUrl($this->config['route']['edit']['name'], ['mail' => $smail, 'hash' => $this->slugger->hash($smail)]+$this->config['route']['edit']['context']),
//Set method
//Redirect to cleanup the form
return $this->redirectToRoute($this->config['route']['edit']['name'], ['mail' => $smail = $this->slugger->short($mail), 'hash' => $this->slugger->hash($smail)]+$this->config['route']['edit']['context']);
//Redirect to cleanup the form
return $this->redirectToRoute($this->config['route']['edit']['name'], ['mail' => $smail = $this->slugger->short($mail), 'hash' => $this->slugger->hash($smail)]+$this->config['route']['edit']['context']);
//Redirect to cleanup the form
return $this->redirectToRoute($this->config['route']['edit']['name'], ['mail' => $smail = $this->slugger->short($mail), 'hash' => $this->slugger->hash($smail)]+$this->config['route']['edit']['context']);
//Catch double slug or mail
} catch (UniqueConstraintViolationException $e) {
//Add error message mail already exists
//Redirect to cleanup the form
return $this->redirectToRoute($this->config['route']['edit']['name'], ['mail' => $smail = $this->slugger->short($mail), 'hash' => $this->slugger->hash($smail)]+$this->config['route']['edit']['context']);
//Catch double slug or mail
} catch (UniqueConstraintViolationException $e) {
//Add error message mail already exists
*/
public function login(Request $request, AuthenticationUtils $authenticationUtils, ?string $hash, ?string $mail): Response {
//Create the LoginType form and give the proper parameters
*/
public function login(Request $request, AuthenticationUtils $authenticationUtils, ?string $hash, ?string $mail): Response {
//Create the LoginType form and give the proper parameters
//Set action to login route name and context
'action' => $this->generateUrl($this->config['route']['login']['name'], $this->config['route']['login']['context']),
//Set method
//Set action to login route name and context
'action' => $this->generateUrl($this->config['route']['login']['name'], $this->config['route']['login']['context']),
//Set method
$login->get('mail')->addError(new FormError($error));
//Create the RecoverType form and give the proper parameters
$login->get('mail')->addError(new FormError($error));
//Create the RecoverType form and give the proper parameters
//Set action to recover route name and context
'action' => $this->generateUrl($this->config['route']['recover']['name'], $this->config['route']['recover']['context']),
//Without password
//Set action to recover route name and context
'action' => $this->generateUrl($this->config['route']['recover']['name'], $this->config['route']['recover']['context']),
//Without password
if (empty($user = $this->doctrine->getRepository($this->config['class']['user'])->findOneByMail($mail))) {
//Throw not found
//XXX: prevent slugger reverse engineering by not displaying decoded mail
if (empty($user = $this->doctrine->getRepository($this->config['class']['user'])->findOneByMail($mail))) {
//Throw not found
//XXX: prevent slugger reverse engineering by not displaying decoded mail
//Set action to recover route name and context
'action' => $this->generateUrl($this->config['route']['recover']['name'], $context+$this->config['route']['recover']['context']),
//With user disable mail
//Set action to recover route name and context
'action' => $this->generateUrl($this->config['route']['recover']['name'], $context+$this->config['route']['recover']['context']),
//With user disable mail
//Set recipient
//XXX: remove the debug set in vendor/symfony/mime/Address.php +46
->to(new Address($context['recipient_mail'], $context['recipient_name']))
//Set recipient
//XXX: remove the debug set in vendor/symfony/mime/Address.php +46
->to(new Address($context['recipient_mail'], $context['recipient_name']))
- $this->addFlash('notice', $this->translator->trans('Your recovery mail has been sent, to retrieve your account you must follow the recuperate link inside'));
+ $this->addFlash('notice', $this->translator->trans('Your recovery mail has been sent, to retrieve your account follow the recuperate link inside'));
- $this->addFlash('warning', $this->translator->trans('If you did not receive a recovery mail, check your Spam or Junk mail folders'));
+ $this->addFlash('warning', $this->translator->trans('If you did not receive a recovery mail, check your Spam or Junk mail folder'));
//Redirect on the same route with sent=1 to cleanup form
return $this->redirectToRoute($request->get('_route'), ['sent' => 1]+$request->get('_route_params'), 302);
//Redirect on the same route with sent=1 to cleanup form
return $this->redirectToRoute($request->get('_route'), ['sent' => 1]+$request->get('_route_params'), 302);
[
'%mail%' => $postMail = $_POST['register']['mail'],
'%locale%' => $request->getLocale(),
[
'%mail%' => $postMail = $_POST['register']['mail'],
'%locale%' => $request->getLocale(),
'hash' => $this->slugger->hash($postSmail)
]+$this->config['route']['confirm']['context'],
UrlGeneratorInterface::ABSOLUTE_URL
'hash' => $this->slugger->hash($postSmail)
]+$this->config['route']['confirm']['context'],
UrlGeneratorInterface::ABSOLUTE_URL
$user = $reflection->newInstance('', '');
//Create the RegisterType form and give the proper parameters
$user = $reflection->newInstance('', '');
//Create the RegisterType form and give the proper parameters
//Set action to register route name and context
'action' => $this->generateUrl($this->config['route']['register']['name'], $this->config['route']['register']['context']),
//Set action to register route name and context
'action' => $this->generateUrl($this->config['route']['register']['name'], $this->config['route']['register']['context']),
//Set recipient
//XXX: remove the debug set in vendor/symfony/mime/Address.php +46
->to(new Address($context['recipient_mail'], $context['recipient_name']))
//Set recipient
//XXX: remove the debug set in vendor/symfony/mime/Address.php +46
->to(new Address($context['recipient_mail'], $context['recipient_name']))