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;
- throw new BadRequestHttpException($this->translator->trans('Invalid %field% field: %value%', ['%field%' => 'hash', '%value%' => $hash]));
+ throw new BadRequestHttpException($this->translator->trans('Invalid %field% field: %value%', ['%field%' => 'hash', '%value%' => $hash], $this->alias));
if (filter_var($mail, FILTER_VALIDATE_EMAIL) === false) {
//Throw bad request
//XXX: prevent slugger reverse engineering by not displaying decoded mail
if (filter_var($mail, FILTER_VALIDATE_EMAIL) === false) {
//Throw bad request
//XXX: prevent slugger reverse engineering by not displaying decoded mail
- throw new BadRequestHttpException($this->translator->trans('Invalid %field% field: %value%', ['%field%' => 'mail', '%value%' => $smail]));
+ throw new BadRequestHttpException($this->translator->trans('Invalid %field% field: %value%', ['%field%' => 'mail', '%value%' => $smail], $this->alias));
}
//Without existing registrant
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
}
//Without existing registrant
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']);
//Redirect to user view
return $this->redirectToRoute($this->config['route']['edit']['name'], ['mail' => $smail, 'hash' => $this->slugger->hash($smail)]+$this->config['route']['edit']['context']);
//Redirect to user view
return $this->redirectToRoute($this->config['route']['edit']['name'], ['mail' => $smail, 'hash' => $this->slugger->hash($smail)]+$this->config['route']['edit']['context']);
- throw new BadRequestHttpException($this->translator->trans('Invalid %field% field: %value%', ['%field%' => 'hash', '%value%' => $hash]));
+ throw new BadRequestHttpException($this->translator->trans('Invalid %field% field: %value%', ['%field%' => 'hash', '%value%' => $hash], $this->alias));
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
'civility_class' => $this->config['class']['civility'],
//Set civility default
'civility_default' => $this->doctrine->getRepository($this->config['class']['civility'])->findOneByTitle($this->config['default']['civility']),
'civility_class' => $this->config['class']['civility'],
//Set civility default
'civility_default' => $this->doctrine->getRepository($this->config['class']['civility'])->findOneByTitle($this->config['default']['civility']),
//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
}
}
//Without admin role
//XXX: prefer a reset on login to force user unspam action
} elseif (!$this->checker->isGranted($this->config['default']['admin'])) {
//Add notice
}
}
//Without admin role
//XXX: prefer a reset on login to force user unspam action
} elseif (!$this->checker->isGranted($this->config['default']['admin'])) {
//Add notice
- $this->addFlash('notice', $this->translator->trans('To change your password login with your mail and any password then follow the procedure'));
+ $this->addFlash('notice', $this->translator->trans('To change your password login with your mail and any password then follow the procedure', [], $this->alias));
- ['edit' => $edit->createView(), 'sent' => $request->query->get('sent', 0)]+$this->config['edit']['view']['context']
+ ['register' => $edit->createView(), 'sent' => $request->query->get('sent', 0)]+$this->config['edit']['view']['context']
//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
- throw new BadRequestHttpException($this->translator->trans('Invalid %field% field: %value%', ['%field%' => 'hash', '%value%' => $hash]));
+ throw new BadRequestHttpException($this->translator->trans('Invalid %field% field: %value%', ['%field%' => 'hash', '%value%' => $hash], $this->alias));
- throw new BadRequestHttpException($this->translator->trans('Invalid %field% field: %value%', ['%field%' => 'mail', '%value%' => $smail]));
+ throw new BadRequestHttpException($this->translator->trans('Invalid %field% field: %value%', ['%field%' => 'mail', '%value%' => $smail], $this->alias));
//Get the login error if there is one
if ($error = $authenticationUtils->getLastAuthenticationError()) {
//Get translated error
//Get the login error if there is one
if ($error = $authenticationUtils->getLastAuthenticationError()) {
//Get translated error
- $this->addFlash('notice', $this->translator->trans('To change your password login with your mail and any password then follow the procedure'));
+ $this->addFlash('notice', $this->translator->trans('To change your password login with your mail and any password then follow the procedure', [], $this->alias));
- throw new BadRequestHttpException($this->translator->trans('Invalid %field% field: %value%', ['%field%' => 'hash', '%value%' => $hash]));
+ throw new BadRequestHttpException($this->translator->trans('Invalid %field% field: %value%', ['%field%' => 'hash', '%value%' => $hash], $this->alias));
if (filter_var($mail, FILTER_VALIDATE_EMAIL) === false) {
//Throw bad request
//XXX: prevent slugger reverse engineering by not displaying decoded mail
if (filter_var($mail, FILTER_VALIDATE_EMAIL) === false) {
//Throw bad request
//XXX: prevent slugger reverse engineering by not displaying decoded mail
- throw new BadRequestHttpException($this->translator->trans('Invalid %field% field: %value%', ['%field%' => 'mail', '%value%' => $smail]));
+ throw new BadRequestHttpException($this->translator->trans('Invalid %field% field: %value%', ['%field%' => 'mail', '%value%' => $smail], $this->alias));
}
//With existing subscriber
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
}
//With existing subscriber
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
}
//With unmatched pass
if ($pass != $this->slugger->hash($user->getPassword())) {
//Throw not found
//XXX: prevent use of outdated recover link
}
//With unmatched pass
if ($pass != $this->slugger->hash($user->getPassword())) {
//Throw not found
//XXX: prevent use of outdated recover link
//With user enable password
'password' => ($user !== null),
//Set method
//With user enable password
'password' => ($user !== null),
//Set method
//Redirect to user login
return $this->redirectToRoute($this->config['route']['login']['name'], ['mail' => $smail, 'hash' => $this->slugger->hash($smail)]+$this->config['route']['login']['context']);
//Redirect to user login
return $this->redirectToRoute($this->config['route']['login']['name'], ['mail' => $smail, 'hash' => $this->slugger->hash($smail)]+$this->config['route']['login']['context']);
$context['subject'] = $subject = ucfirst(
$this->translator->trans(
$this->config['recover']['mail']['subject'],
$context['subject'] = $subject = ucfirst(
$this->translator->trans(
$this->config['recover']['mail']['subject'],
- $this->slugger->flatten($context, null, '.', '%', '%')
+ $this->slugger->flatten($context, null, '.', '%', '%'),
+ $this->alias
- ->from(new Address($this->config['contact']['address'], $this->translator->trans($this->config['contact']['name'])))
+ ->from(new Address($this->config['contact']['address'], $this->translator->trans($this->config['contact']['name'], [], $this->alias)))
//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 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->alias));
- $this->addFlash('warning', $this->translator->trans('If you did not receive a recovery mail, check your Spam or Junk mail folder'));
+ $this->addFlash('warning', $this->translator->trans('If you did not receive a recovery mail, check your Spam or Junk mail folder', [], $this->alias));
//Redirect on the same route with sent=1 to cleanup form
return $this->redirectToRoute($request->get('_route'), ['sent' => 1]+$request->get('_route_params'), 302);
//Catch obvious transport exception
} catch(TransportExceptionInterface $e) {
//Add error message mail unreachable
//Redirect on the same route with sent=1 to cleanup form
return $this->redirectToRoute($request->get('_route'), ['sent' => 1]+$request->get('_route_params'), 302);
//Catch obvious transport exception
} catch(TransportExceptionInterface $e) {
//Add error message mail unreachable
$form = $this->factory->create($this->config['register']['view']['form'], $user, [
//Set action to register route name and context
'action' => $this->generateUrl($this->config['route']['register']['name'], $this->config['route']['register']['context']),
$form = $this->factory->create($this->config['register']['view']['form'], $user, [
//Set action to register route name and context
'action' => $this->generateUrl($this->config['route']['register']['name'], $this->config['route']['register']['context']),
//Set civility class
'civility_class' => $this->config['class']['civility'],
//Set civility default
'civility_default' => $this->doctrine->getRepository($this->config['class']['civility'])->findOneByTitle($this->config['default']['civility']),
//Set method
//Set civility class
'civility_class' => $this->config['class']['civility'],
//Set civility default
'civility_default' => $this->doctrine->getRepository($this->config['class']['civility'])->findOneByTitle($this->config['default']['civility']),
//Set method
- throw new \Exception(sprintf('Group %s listed in %s.default.group[%d] not found by title', $groupTitle, RapsysUserBundle::getAlias(), $i));
+ throw new \Exception(sprintf('Group %s listed in %s.default.group[%d] not found by title', $groupTitle, $this->alias, $i));
$context['subject'] = $subject = ucfirst(
$this->translator->trans(
$this->config['register']['mail']['subject'],
$context['subject'] = $subject = ucfirst(
$this->translator->trans(
$this->config['register']['mail']['subject'],
- $this->slugger->flatten($context, null, '.', '%', '%')
+ $this->slugger->flatten($context, null, '.', '%', '%'),
+ $this->alias
- ->from(new Address($this->config['contact']['address'], $this->translator->trans($this->config['contact']['name'])))
+ ->from(new Address($this->config['contact']['address'], $this->translator->trans($this->config['contact']['name'], [], $this->alias)))
//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']))
//Catch obvious transport exception
} catch(TransportExceptionInterface $e) {
//Add error message mail unreachable
//Catch obvious transport exception
} catch(TransportExceptionInterface $e) {
//Add error message mail unreachable
}
//Catch double subscription
} catch (UniqueConstraintViolationException $e) {
//Add error message mail already exists
}
//Catch double subscription
} catch (UniqueConstraintViolationException $e) {
//Add error message mail already exists