|
@@ -161,54 +161,52 @@ class UserController extends Controller
|
161
|
161
|
$form = $this->container->get('fos_user.registration.form');
|
162
|
162
|
$formHandler = $this->container->get('fos_user.registration.form.handler');
|
163
|
163
|
$confirmationEnabled = $this->container->getParameter('fos_user.registration.confirmation.enabled');
|
|
164
|
+ $errors = array();
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+ $form_values = $this->getRequest()->request->get($form->getName());
|
|
168
|
+ $r_token = $this->getDoctrine()->getRepository('MuzichCoreBundle:RegistrationToken')
|
|
169
|
+ ->findOneBy(array('token' => $form_values["token"], 'used' => false))
|
|
170
|
+ ;
|
164
|
171
|
|
165
|
|
-
|
166
|
|
- if (count(($errors = $this->checkRegistrationInformations($form))) < 1)
|
|
172
|
+ if ($r_token)
|
167
|
173
|
{
|
168
|
|
- $process = $formHandler->process($confirmationEnabled);
|
169
|
|
- if ($process) {
|
170
|
|
- $user = $form->getData();
|
171
|
|
-
|
172
|
|
- if ($confirmationEnabled) {
|
173
|
|
- $this->container->get('session')->set('fos_user_send_confirmation_email/email', $user->getEmail());
|
174
|
|
- $route = 'fos_user_registration_check_email';
|
175
|
|
- } else {
|
176
|
|
- $this->authenticateUser($user);
|
177
|
|
- $route = 'start';
|
178
|
|
- }
|
179
|
|
-
|
180
|
|
- $this->setFlash('fos_user_success', 'registration.flash.user_created');
|
181
|
|
- $url = $this->generateUrl($route);
|
182
|
|
-
|
183
|
|
-
|
184
|
|
-
|
185
|
|
- * Contrôle du token
|
186
|
|
- */
|
187
|
|
- $form_values = $this->getRequest()->request->get($form->getName());
|
188
|
|
- $r_token = $this->getDoctrine()->getRepository('MuzichCoreBundle:RegistrationToken')
|
189
|
|
- ->findOneBy(array('token' => $form_values["token"], 'used' => false))
|
190
|
|
- ;
|
|
174
|
+ if (count(($errors = $this->checkRegistrationInformations($form))) < 1)
|
|
175
|
+ {
|
|
176
|
+ $process = $formHandler->process($confirmationEnabled);
|
|
177
|
+ if ($process) {
|
|
178
|
+ $user = $form->getData();
|
|
179
|
+
|
|
180
|
+ if ($confirmationEnabled) {
|
|
181
|
+ $this->container->get('session')->set('fos_user_send_confirmation_email/email', $user->getEmail());
|
|
182
|
+ $route = 'fos_user_registration_check_email';
|
|
183
|
+ } else {
|
|
184
|
+ $this->authenticateUser($user);
|
|
185
|
+ $route = 'start';
|
|
186
|
+ }
|
191
|
187
|
|
192
|
|
- if (!$r_token)
|
193
|
|
- {
|
194
|
|
- $errors[] = $this->get('translator')->trans(
|
195
|
|
- 'registration.token.error',
|
196
|
|
- array(),
|
197
|
|
- 'validators'
|
198
|
|
- );
|
199
|
|
- }
|
200
|
|
- else
|
201
|
|
- {
|
202
|
|
- $r_token->setUsed(true);
|
|
188
|
+ $this->setFlash('fos_user_success', 'registration.flash.user_created');
|
|
189
|
+ $url = $this->generateUrl($route);
|
|
190
|
+
|
|
191
|
+ $r_token->addUseCount();
|
203
|
192
|
$em = $this->getDoctrine()->getEntityManager();
|
204
|
193
|
$em->persist($r_token);
|
205
|
194
|
$em->flush();
|
|
195
|
+
|
|
196
|
+ return new RedirectResponse($url);
|
206
|
197
|
}
|
207
|
|
-
|
208
|
|
- return new RedirectResponse($url);
|
209
|
198
|
}
|
210
|
199
|
}
|
211
|
|
-
|
|
200
|
+ else
|
|
201
|
+ {
|
|
202
|
+ $form->bindRequest($this->getRequest());
|
|
203
|
+ $errors[] = $this->get('translator')->trans(
|
|
204
|
+ 'registration.token.error',
|
|
205
|
+ array(),
|
|
206
|
+ 'validators'
|
|
207
|
+ );
|
|
208
|
+ }
|
|
209
|
+
|
212
|
210
|
return $this->container->get('templating')->renderResponse(
|
213
|
211
|
'MuzichIndexBundle:Index:index.html.twig',
|
214
|
212
|
array(
|