Ver código fonte

Evolution #582: Implémenter le mode nopass

Sevajol Bastien 11 anos atrás
pai
commit
96570f0c56

+ 3 - 1
app/Resources/translations/userform.en.yml Ver arquivo

@@ -1,4 +1,6 @@
1 1
 
2 2
 password.actual: Actual
3 3
 password.new.first: New
4
-password.new.second: New (check)
4
+password.new.second: New (check)
5
+
6
+accept_cgu_registration: By processing registration you accept <a href="%link%">terms of service</a> of muzi.ch

+ 3 - 1
app/Resources/translations/userform.fr.yml Ver arquivo

@@ -16,4 +16,6 @@ cgu_accepted:     J'ai lu et j'accepete les <a href="%url%">condition générale
16 16
 help:
17 17
   token:   |
18 18
             Rentrez ici le code qui vous à été fourni afin de vous inscrire 
19
-            à la version non publique.
19
+            à la version non publique.
20
+
21
+accept_cgu_registration: En procédant à l'inscription vous acceptez les <a href="%link%">conditions générales d'utilisation</a> de muzi.ch

+ 5 - 0
src/Muzich/CoreBundle/Resources/public/css/main.css Ver arquivo

@@ -2050,4 +2050,9 @@ div.helpbox_image_container img
2050 2050
 div.side_margin_top
2051 2051
 {
2052 2052
   margin-top: 25px;
2053
+}
2054
+
2055
+p.accept_cgu
2056
+{
2057
+  font-size: 11px;
2053 2058
 }

+ 9 - 2
src/Muzich/IndexBundle/Controller/IndexController.php Ver arquivo

@@ -8,6 +8,8 @@ use Symfony\Component\Security\Core\SecurityContext;
8 8
 use Symfony\Component\Validator\Constraints\Email;
9 9
 use Symfony\Component\Validator\Constraints\Collection;
10 10
 use Symfony\Component\HttpFoundation\Request;
11
+use Muzich\UserBundle\Form\Type\RegistrationFormType;
12
+use Muzich\CoreBundle\Entity\User;
11 13
 
12 14
 class IndexController extends Controller
13 15
 {
@@ -25,7 +27,7 @@ class IndexController extends Controller
25 27
     }
26 28
     
27 29
     $vars = $this->proceedLogin();
28
-    $form = $this->container->get('fos_user.registration.form');
30
+    $form = $this->getRegistrationForm();
29 31
     
30 32
     return $this->render('MuzichIndexBundle:Index:index.html.twig', array_merge($vars, array(
31 33
       'form' => $form->createView(),
@@ -33,6 +35,11 @@ class IndexController extends Controller
33 35
     )));
34 36
   }
35 37
   
38
+  protected function getRegistrationForm()
39
+  {
40
+    return $this->createForm(new RegistrationFormType(), new User());
41
+  }
42
+  
36 43
   /**
37 44
    * Gestion du formulaire d'identification sur la page d'index.
38 45
    * 
@@ -104,7 +111,7 @@ class IndexController extends Controller
104 111
     
105 112
     $this->setFlash('error', 'presubscription.error');
106 113
     return $this->render('MuzichIndexBundle:Index:index.html.twig', array(
107
-      'form' => $this->container->get('fos_user.registration.form')->createView(),
114
+      'form' => $this->getRegistrationForm()->createView(),
108 115
       'presubscription_form' => $form->createView(),
109 116
       'last_username' => '',
110 117
       'error'         => '',

+ 9 - 39
src/Muzich/UserBundle/Controller/UserController.php Ver arquivo

@@ -135,7 +135,7 @@ class UserController extends Controller
135 135
   {
136 136
     $userManager = $this->container->get('fos_user.user_manager');
137 137
     $user = $this->getNewUser($userManager);
138
-    $form = $this->createForm(new RegistrationFormType(), $user);
138
+    $form = $this->getRegistrationForm($user);
139 139
     $form->bindRequest($request);
140 140
     
141 141
     if ($form->isValid())
@@ -149,9 +149,15 @@ class UserController extends Controller
149 149
     return $this->getFailureRegistrationResponse($form);
150 150
   }
151 151
   
152
+  protected function getRegistrationForm(User $user)
153
+  {
154
+    return $this->createForm(new RegistrationFormType(), $user);
155
+  }
156
+  
152 157
   /** @return User */
153
-  protected function getNewUser($userManager)
158
+  protected function getNewUser()
154 159
   {
160
+    $userManager = $this->container->get('fos_user.user_manager');
155 161
     $user = $userManager->createUser();
156 162
     $user->setUsername($this->generateUsername());
157 163
     $user->setPlainPassword($this->generatePassword(32));
@@ -182,42 +188,6 @@ class UserController extends Controller
182 188
     return $result;
183 189
   }
184 190
   
185
-  public function registerOldAction()
186
-  {
187
-    $form = $this->container->get('fos_user.registration.form');
188
-    $formHandler = $this->container->get('fos_user.registration.form.handler');
189
-    $confirmationEnabled = $this->container->getParameter('fos_user.registration.confirmation.enabled');
190
-    
191
-    $process = $formHandler->process($confirmationEnabled);
192
-    if ($process)
193
-    {
194
-      $user = $form->getData();
195
-      
196
-      $authUser = false;
197
-      if ($confirmationEnabled) {
198
-          $this->container->get('session')->set('fos_user_send_confirmation_email/email', $user->getEmail());
199
-          $route = 'fos_user_registration_check_email';
200
-      } else {
201
-          $authUser = true;
202
-          $route = 'start';
203
-      }
204
-      
205
-      $response = $this->getSuccessRegistrationResponse();
206
-      if ($authUser) {
207
-        $this->authenticateUser($user, $response);
208
-      }
209
-      
210
-      $formHandler->getToken()->addUseCount();
211
-      $em = $this->getDoctrine()->getEntityManager();
212
-      $em->persist($formHandler->getToken());
213
-      $em->flush();
214
-      
215
-      return $response;
216
-    }
217
-    
218
-    return $this->getFailureRegistrationResponse($form, $formHandler);
219
-  }
220
-  
221 191
   protected function getSuccessRegistrationResponse()
222 192
   {
223 193
     if (!$this->getRequest()->isXmlHttpRequest())
@@ -692,7 +662,7 @@ class UserController extends Controller
692 662
     return $this->jsonResponse(array(
693 663
       'status' => 'success',
694 664
       'data'   => $this->render('MuzichUserBundle:Account:subscribe_or_login.html.twig', array(
695
-        'form' => $this->container->get('fos_user.registration.form')->createView()
665
+        'form' => $this->getRegistrationForm($this->getNewUser())->createView()
696 666
       ))->getContent()
697 667
     ));
698 668
   }

+ 9 - 1
src/Muzich/UserBundle/Resources/views/Registration/register_form_content.html.twig Ver arquivo

@@ -20,9 +20,17 @@
20 20
   {{ form_widget(form.email, {'attr':{'class':'niceinput'}}) }}
21 21
 </div> 
22 22
 
23
-{{ form_rest(form) }}
23
+{{ form_widget(form._token) }}
24 24
 
25 25
 <div class="alignright">
26 26
   <img class="loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading" />
27 27
   <input type="submit" class="button" value="{{ 'registration.submit'|trans({}, 'userui') }}" />
28 28
 </div>
29
+
30
+<p class="accept_cgu">
31
+  {% autoescape false %}
32
+    {{ 'accept_cgu_registration'|trans({
33
+      '%link%' : path('info_cgu')
34
+    }, 'userform' )}}
35
+  {% endautoescape %}
36
+</p>