A user in Oscar is identified by email address instead of the username. This is, however, not set as a ``unique`` constraint in the user model in ``django.contrib.auth.models.User``. Checks if an email already exists are carried out when a user registers but are ignored when a registered user changes their profile. This can lead to multiple users having the same email address which should not happen. I provide a failing test with a mixin that can be used in both the ``UserForm`` and ``UserAndProfileForm`` to clean the email field when validating the form. A ``ValidationError`` is raised when a user with this email address already exists and is not the currently edited instance (makes sure that profile updates with unchanged email work still). Fixes #324master
|
|
||
| 10 |
|
10 |
|
| 11 |
|
11 |
|
| 12 |
|
12 |
|
|
13 |
|
|
| 13 |
|
14 |
|
| 14 |
|
15 |
|
| 15 |
|
16 |
|
|
|
||
| 211 |
|
212 |
|
| 212 |
|
213 |
|
| 213 |
|
214 |
|
| 214 |
|
|
|
|
215 |
|
|
|
216 |
|
|
|
217 |
|
|
|
218 |
|
|
|
219 |
|
|
|
220 |
|
|
|
221 |
|
|
|
222 |
|
|
|
223 |
|
|
|
224 |
|
|
|
225 |
|
|
|
226 |
|
|
|
227 |
|
|
|
228 |
|
|
|
229 |
|
|
|
230 |
|
|
|
231 |
|
|
|
232 |
|
|
|
233 |
|
|
|
234 |
|
|
|
235 |
|
|
|
236 |
|
|
|
237 |
|
|
|
238 |
|
|
|
239 |
|
|
|
240 |
|
|
|
241 |
|
|
| 215 |
|
242 |
|
| 216 |
|
243 |
|
| 217 |
|
244 |
|
|
|
||
| 229 |
|
256 |
|
| 230 |
|
257 |
|
| 231 |
|
258 |
|
| 232 |
|
|
|
|
259 |
|
|
| 233 |
|
260 |
|
| 234 |
|
261 |
|
| 235 |
|
262 |
|
|
|
||
| 1 |
|
|
|
| 2 |
|
1 |
|
| 3 |
|
2 |
|
| 4 |
|
3 |
|
| 5 |
|
4 |
|
| 6 |
|
5 |
|
| 7 |
|
|
|
| 8 |
|
|
|
| 9 |
|
6 |
|
| 10 |
|
7 |
|
| 11 |
|
8 |
|
|
|
||
| 45 |
|
42 |
|
| 46 |
|
43 |
|
| 47 |
|
44 |
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
| 48 |
|
70 |
|
| 49 |
|
71 |
|
| 50 |
|
72 |
|