0001-misc-ignore-case-when-searching-by-email-42880.patch
src/authentic2/api_views.py | ||
---|---|---|
321 | 321 | |
322 | 322 |
def validate(self, data): |
323 | 323 |
User = get_user_model() |
324 |
qs = User.objects.filter(email=data['email']) |
|
324 |
qs = User.objects.filter(email__iexact=data['email'])
|
|
325 | 325 |
if data['ou']: |
326 | 326 |
qs = qs.filter(ou=data['ou']) |
327 | 327 |
try: |
... | ... | |
512 | 512 |
and data.get('email') |
513 | 513 |
and (not self.instance or data.get('email') != self.instance.email) |
514 | 514 |
): |
515 |
if app_settings.A2_EMAIL_IS_UNIQUE and qs.filter(email=data['email']).exists(): |
|
515 |
if app_settings.A2_EMAIL_IS_UNIQUE and qs.filter(email__iexact=data['email']).exists():
|
|
516 | 516 |
already_used = True |
517 |
if ou and ou.email_is_unique and qs.filter(ou=ou, email=data['email']).exists(): |
|
517 |
if ou and ou.email_is_unique and qs.filter(ou=ou, email__iexact=data['email']).exists():
|
|
518 | 518 |
already_used = True |
519 | 519 | |
520 | 520 |
errors = {} |
src/authentic2/custom_user/management/commands/changepassword.py | ||
---|---|---|
54 | 54 |
UserModel = get_user_model() |
55 | 55 | |
56 | 56 |
qs = UserModel._default_manager.using(options.get('database')) |
57 |
qs = qs.filter(Q(uuid=username) | Q(username=username) | Q(email=username)) |
|
57 |
qs = qs.filter(Q(uuid=username) | Q(username=username) | Q(email__iexact=username))
|
|
58 | 58 |
try: |
59 | 59 |
u = qs.get() |
60 | 60 |
except UserModel.DoesNotExist: |
src/authentic2/utils/misc.py | ||
---|---|---|
770 | 770 |
data[REDIRECT_FIELD_NAME] = next_url |
771 | 771 |
lifetime = settings.ACCOUNT_ACTIVATION_DAYS * 3600 * 24 |
772 | 772 |
# invalidate any token associated with this address |
773 |
Token.objects.filter(kind='registration', content__email=email).delete() |
|
773 |
Token.objects.filter(kind='registration', content__email__iexact=email).delete()
|
|
774 | 774 |
token = Token.create('registration', data, duration=lifetime) |
775 | 775 |
activate_url = request.build_absolute_uri( |
776 | 776 |
reverse('registration_activate', kwargs={'registration_token': token.uuid_b64url}) |
... | ... | |
804 | 804 |
registration_url = build_activation_url(request, email=email, next_url=next_url, ou=ou, **kwargs) |
805 | 805 | |
806 | 806 |
# existing accounts |
807 |
existing_accounts = User.objects.filter(email=email) |
|
807 |
existing_accounts = User.objects.filter(email__iexact=email)
|
|
808 | 808 |
if not app_settings.A2_EMAIL_IS_UNIQUE: |
809 |
existing_accounts = existing_accounts.filter(ou=ou, email=email)
|
|
809 |
existing_accounts = existing_accounts.filter(ou=ou) |
|
810 | 810 | |
811 | 811 |
# ctx for rendering the templates |
812 | 812 |
context = context or {} |
src/authentic2/views.py | ||
---|---|---|
236 | 236 |
user = User.objects.get(pk=user_pk) |
237 | 237 |
non_unique = False |
238 | 238 |
if app_settings.A2_EMAIL_IS_UNIQUE: |
239 |
non_unique = User.objects.filter(email=email).exclude(pk=user_pk).exists() |
|
239 |
non_unique = User.objects.filter(email__iexact=email).exclude(pk=user_pk).exists()
|
|
240 | 240 |
elif user.ou and user.ou.email_is_unique: |
241 |
non_unique = User.objects.filter(email=email, ou=user.ou).exclude(pk=user_pk).exists() |
|
241 |
non_unique = ( |
|
242 |
User.objects.filter(email__iexact=email, ou=user.ou).exclude(pk=user_pk).exists() |
|
243 |
) |
|
242 | 244 |
if non_unique: |
243 | 245 |
raise ValidationError(_('This email is already used by another account.')) |
244 | 246 |
old_email = user.email |
... | ... | |
716 | 718 | |
717 | 719 |
# if an email has already been sent, warn once before allowing resend |
718 | 720 |
token = models.Token.objects.filter( |
719 |
kind='pw-reset', content__email=email, expires__gt=timezone.now() |
|
721 |
kind='pw-reset', content__email__iexact=email, expires__gt=timezone.now()
|
|
720 | 722 |
).exists() |
721 | 723 |
resend_key = 'pw-reset-allow-resend' |
722 | 724 |
if app_settings.A2_TOKEN_EXISTS_WARNING and token and not self.request.session.get(resend_key): |
... | ... | |
901 | 903 | |
902 | 904 |
# if an email has already been sent, warn once before allowing resend |
903 | 905 |
token = models.Token.objects.filter( |
904 |
kind='registration', content__email=email, expires__gt=timezone.now() |
|
906 |
kind='registration', content__email__iexact=email, expires__gt=timezone.now()
|
|
905 | 907 |
).exists() |
906 | 908 |
resend_key = 'registration-allow-resend' |
907 | 909 |
if app_settings.A2_TOKEN_EXISTS_WARNING and token and not self.request.session.get(resend_key): |
src/authentic2_auth_fc/views.py | ||
---|---|---|
485 | 485 |
ou = get_default_ou() |
486 | 486 | |
487 | 487 |
if a2_app_settings.A2_EMAIL_IS_UNIQUE: |
488 |
instance, created = safe_get_or_create(User, email=email, defaults={'email': email, 'ou': ou}) |
|
488 |
instance, created = safe_get_or_create( |
|
489 |
User, email__iexact=email, defaults={'email': email, 'ou': ou} |
|
490 |
) |
|
489 | 491 |
if instance.ou != ou: |
490 | 492 |
assert not created # should not be possible |
491 | 493 |
raise UserOutsideDefaultOu |
492 | 494 |
return instance, created |
493 | 495 |
elif ou.email_is_unique: |
494 |
return safe_get_or_create(User, ou=ou, email=email, defaults={'email': email, 'ou': ou}) |
|
496 |
return safe_get_or_create(User, ou=ou, email__iexact=email, defaults={'email': email, 'ou': ou})
|
|
495 | 497 |
else: |
496 | 498 |
return User.objects.create(email=email), True |
497 | 499 | |
498 |
- |