Browse Source

Correction du bug du token devenant invalide si formulaire d'inscription raté 1 fois.

Sevajol Bastien 12 years ago
parent
commit
c416218a14
1 changed files with 25 additions and 23 deletions
  1. 25 23
      src/Muzich/UserBundle/Controller/UserController.php

+ 25 - 23
src/Muzich/UserBundle/Controller/UserController.php View File

@@ -107,29 +107,6 @@ class UserController extends Controller
107 107
     $form_values = $this->getRequest()->request->get($form->getName());
108 108
     $user = $form->getData();
109 109
     
110
-    /**
111
-     * Contrôle du token
112
-     */
113
-    
114
-    $r_token = $this->getDoctrine()->getRepository('MuzichCoreBundle:RegistrationToken')
115
-      ->findOneBy(array('token' => $form_values["token"], 'used' => false))
116
-    ;
117
-      
118
-    if (!$r_token)
119
-    {
120
-      $errors[] = $this->get('translator')->trans(
121
-        'registration.token.error', 
122
-        array(),
123
-        'validators'
124
-      );
125
-    }
126
-    else
127
-    {
128
-      $r_token->setUsed(true);
129
-      $em = $this->getDoctrine()->getEntityManager();
130
-      $em->persist($r_token);
131
-      $em->flush();
132
-    }
133 110
     
134 111
     /*
135 112
      * Contrôle de la taille du pseudo
@@ -193,6 +170,31 @@ class UserController extends Controller
193 170
         $this->setFlash('fos_user_success', 'registration.flash.user_created');
194 171
         $url = $this->generateUrl($route);
195 172
 
173
+        
174
+        /**
175
+         * Contrôle du token
176
+         */
177
+        $form_values = $this->getRequest()->request->get($form->getName());
178
+        $r_token = $this->getDoctrine()->getRepository('MuzichCoreBundle:RegistrationToken')
179
+          ->findOneBy(array('token' => $form_values["token"], 'used' => false))
180
+        ;
181
+          
182
+        if (!$r_token)
183
+        {
184
+          $errors[] = $this->get('translator')->trans(
185
+            'registration.token.error', 
186
+            array(),
187
+            'validators'
188
+          );
189
+        }
190
+        else
191
+        {
192
+          $r_token->setUsed(true);
193
+          $em = $this->getDoctrine()->getEntityManager();
194
+          $em->persist($r_token);
195
+          $em->flush();
196
+        }
197
+        
196 198
         return new RedirectResponse($url);
197 199
       }
198 200
     }