- //Add form to context
- $context['application'] = $application->createView();
- //Create login form for anonymous
- } elseif (!$this->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
- //Create ApplicationType form
- $login = $this->createForm('Rapsys\UserBundle\Form\LoginType', null, [
- //Set the action
- 'action' => $this->generateUrl('rapsys_user_login'),
- //Set the form attribute
- 'attr' => [ 'class' => 'col' ]
+ //Prevent access when not admin, user is not guest and not currently logged user
+ if (!$this->isGranted('ROLE_ADMIN') && $user != $this->getUser() || !$this->isGranted('IS_AUTHENTICATED_FULLY')) {
+ //Throw access denied
+ //XXX: prevent slugger reverse engineering by not displaying decoded mail
+ throw $this->createAccessDeniedException($this->translator->trans('Unable to access user: %mail%', ['%mail%' => $smail]));
+ }
+
+ //With admin
+ if ($this->isGranted('ROLE_ADMIN')) {
+ //With pseudonym and without slug
+ if (!empty($pseudonym = $user->getPseudonym()) && empty($user->getSlug())) {
+ //Preset slug
+ $user->setSlug($slugger->slug($pseudonym));
+ }
+ }
+
+ //Create the RegisterType form and give the proper parameters
+ $edit = $this->createForm($this->config['edit']['view']['edit'], $user, [
+ //Set action to register route name and context
+ 'action' => $this->generateUrl($this->config['route']['edit']['name'], ['mail' => $smail, 'hash' => $slugger->hash($smail)]+$this->config['route']['edit']['context']),
+ //Set civility class
+ 'civility_class' => $this->config['class']['civility'],
+ //Set civility default
+ 'civility_default' => $doctrine->getRepository($this->config['class']['civility'])->findOneByTitle($this->config['default']['civility']),
+ //Disable mail
+ 'mail' => $this->isGranted('ROLE_ADMIN'),
+ //Disable pseudonym
+ 'pseudonym' => $this->isGranted('ROLE_GUEST'),
+ //Disable slug
+ 'slug' => $this->isGranted('ROLE_ADMIN'),
+ //Disable password
+ 'password' => false,
+ //Set method
+ 'method' => 'POST'
+ ]+$this->config['edit']['field']);
+
+ //With admin role
+ if ($this->isGranted('ROLE_ADMIN')) {
+ //Create the LoginType form and give the proper parameters
+ $reset = $this->createForm($this->config['edit']['view']['reset'], $user, [
+ //Set action to register route name and context
+ 'action' => $this->generateUrl($this->config['route']['edit']['name'], ['mail' => $smail, 'hash' => $slugger->hash($smail)]+$this->config['route']['edit']['context']),
+ //Disable mail
+ 'mail' => false,
+ //Set method
+ 'method' => 'POST'