|
@@ -129,6 +129,35 @@ class UserController extends Controller
|
129
|
129
|
)
|
130
|
130
|
);
|
131
|
131
|
}
|
|
132
|
+
|
|
133
|
+ /**
|
|
134
|
+ * Un bug étrange empêche la mise ne place de contraintes sur le formulaire
|
|
135
|
+ * d'inscription. On effectue alors les vérifications ici.
|
|
136
|
+ *
|
|
137
|
+ * C'est sale, mais ça marche ...
|
|
138
|
+ *
|
|
139
|
+ * @return array of string errors
|
|
140
|
+ */
|
|
141
|
+ protected function checkChangePasswordInformations($form)
|
|
142
|
+ {
|
|
143
|
+ $errors = array();
|
|
144
|
+ $form_values = $this->getRequest()->request->get($form->getName());
|
|
145
|
+ $user = $form->getData();
|
|
146
|
+
|
|
147
|
+ /**
|
|
148
|
+ * Mot de passes indentiques
|
|
149
|
+ */
|
|
150
|
+ if ($form_values['new']['first'] != $form_values['new']['second'])
|
|
151
|
+ {
|
|
152
|
+ $errors[] = $this->get('translator')->trans(
|
|
153
|
+ 'error.changepassword.new.notsame',
|
|
154
|
+ array(),
|
|
155
|
+ 'validators'
|
|
156
|
+ );
|
|
157
|
+ }
|
|
158
|
+
|
|
159
|
+ return $errors;
|
|
160
|
+ }
|
132
|
161
|
|
133
|
162
|
public function changePasswordAction()
|
134
|
163
|
{
|
|
@@ -153,8 +182,7 @@ class UserController extends Controller
|
153
|
182
|
$form = $this->container->get('fos_user.change_password.form');
|
154
|
183
|
$formHandler = $this->container->get('fos_user.change_password.form.handler');
|
155
|
184
|
|
156
|
|
- $process = $formHandler->process($user);
|
157
|
|
- if ($process)
|
|
185
|
+ if (count(($errors = $this->checkChangePasswordInformations($form))) < 1 && $process)
|
158
|
186
|
{
|
159
|
187
|
$this->container->get('session')->setFlash('fos_user_success', 'change_password.flash.success');
|
160
|
188
|
return new RedirectResponse($this->generateUrl('my_account'));
|
|
@@ -172,8 +200,9 @@ class UserController extends Controller
|
172
|
200
|
return $this->container->get('templating')->renderResponse(
|
173
|
201
|
'MuzichUserBundle:User:account.html.twig',
|
174
|
202
|
array(
|
175
|
|
- 'form_password' => $form->createView(),
|
176
|
|
- 'user' => $user,
|
|
203
|
+ 'form_password' => $form->createView(),
|
|
204
|
+ 'errors_pers' => $errors,
|
|
205
|
+ 'user' => $user,
|
177
|
206
|
'form_tags_favorites' => $form_tags_favorites->createView()
|
178
|
207
|
)
|
179
|
208
|
);
|