|
@@ -37,28 +37,70 @@ class UserController extends Controller
|
37
|
37
|
);
|
38
|
38
|
}
|
39
|
39
|
|
|
40
|
+ /**
|
|
41
|
+ * Un bug étrange empêche la mise ne place de contraintes sur le formulaire
|
|
42
|
+ * d'inscription. On effectue alors les vérifications ici.
|
|
43
|
+ *
|
|
44
|
+ * @return array of string errors
|
|
45
|
+ */
|
|
46
|
+ protected function checkRegistrationInformations($form)
|
|
47
|
+ {
|
|
48
|
+ $errors = array();
|
|
49
|
+ $form->bindRequest($this->getRequest());
|
|
50
|
+ $user = $form->getData();
|
|
51
|
+
|
|
52
|
+ /*
|
|
53
|
+ * Contrôle de la taille du pseudo
|
|
54
|
+ * min: 3
|
|
55
|
+ * max: 32
|
|
56
|
+ */
|
|
57
|
+ if (strlen($user->getUsername()) < 3)
|
|
58
|
+ {
|
|
59
|
+ $errors[] = $this->get('translator')->trans(
|
|
60
|
+ 'error.registration.username.min',
|
|
61
|
+ array('%limit%' => 3),
|
|
62
|
+ 'validators'
|
|
63
|
+ );
|
|
64
|
+ }
|
|
65
|
+
|
|
66
|
+ if (strlen($user->getUsername()) > 32)
|
|
67
|
+ {
|
|
68
|
+ $errors[] = $this->get('translator')->trans(
|
|
69
|
+ 'error.registration.username.max',
|
|
70
|
+ array('%limit%' => 32),
|
|
71
|
+ 'validators'
|
|
72
|
+ );
|
|
73
|
+ }
|
|
74
|
+
|
|
75
|
+ return $errors;
|
|
76
|
+ }
|
|
77
|
+
|
40
|
78
|
public function registerAction()
|
41
|
79
|
{
|
42
|
80
|
$form = $this->container->get('fos_user.registration.form');
|
43
|
81
|
$formHandler = $this->container->get('fos_user.registration.form.handler');
|
44
|
82
|
$confirmationEnabled = $this->container->getParameter('fos_user.registration.confirmation.enabled');
|
45
|
83
|
|
46
|
|
- $process = $formHandler->process($confirmationEnabled);
|
47
|
|
- if ($process) {
|
48
|
|
- $user = $form->getData();
|
|
84
|
+ // Pour palier bug, verif interne
|
|
85
|
+ if (count(($errors = $this->checkRegistrationInformations($form))) < 1)
|
|
86
|
+ {
|
|
87
|
+ $process = $formHandler->process($confirmationEnabled);
|
|
88
|
+ if ($process) {
|
|
89
|
+ $user = $form->getData();
|
49
|
90
|
|
50
|
|
- if ($confirmationEnabled) {
|
51
|
|
- $this->container->get('session')->set('fos_user_send_confirmation_email/email', $user->getEmail());
|
52
|
|
- $route = 'fos_user_registration_check_email';
|
53
|
|
- } else {
|
54
|
|
- $this->authenticateUser($user);
|
55
|
|
- $route = 'start';
|
56
|
|
- }
|
|
91
|
+ if ($confirmationEnabled) {
|
|
92
|
+ $this->container->get('session')->set('fos_user_send_confirmation_email/email', $user->getEmail());
|
|
93
|
+ $route = 'fos_user_registration_check_email';
|
|
94
|
+ } else {
|
|
95
|
+ $this->authenticateUser($user);
|
|
96
|
+ $route = 'start';
|
|
97
|
+ }
|
57
|
98
|
|
58
|
|
- $this->setFlash('fos_user_success', 'registration.flash.user_created');
|
59
|
|
- $url = $this->generateUrl($route);
|
|
99
|
+ $this->setFlash('fos_user_success', 'registration.flash.user_created');
|
|
100
|
+ $url = $this->generateUrl($route);
|
60
|
101
|
|
61
|
|
- return new RedirectResponse($url);
|
|
102
|
+ return new RedirectResponse($url);
|
|
103
|
+ }
|
62
|
104
|
}
|
63
|
105
|
|
64
|
106
|
return $this->container->get('templating')->renderResponse(
|
|
@@ -67,6 +109,7 @@ class UserController extends Controller
|
67
|
109
|
'form' => $form->createView(),
|
68
|
110
|
'error' => null,
|
69
|
111
|
'registration_errors' => $form->getErrors(),
|
|
112
|
+ 'registration_errors_pers' => $errors,
|
70
|
113
|
'last_username' => null
|
71
|
114
|
)
|
72
|
115
|
);
|