codingjoe / codingjoe/django-mail-auth

Possible case-sensitivity on postgres?

Open
#209 5 comments 1 reaction 1 assignee Claimed by @reinout View on GitHub
bug help wanted
Dominant language
Python
Stars
110
Forks
5
Avg merge
2d 8h
Merged PRs (30d)
4

Description

The documentation says that django-mail-auth uses a case-insensitive email address. But... the behaviour I just saw on my postgres-using production site was different :-)

I did some digging in the code and found the PR that added case insensitive search: https://github.com/codingjoe/django-mail-auth/pull/5/changes

- On postgres, the PR uses CIEmailfield, which has been deprecated since Django 4.2: https://docs.djangoproject.com/en/4.2/ref/contrib/postgres/fields/#citext-fields
- There's your https://pypi.org/project/django-citext/ library that re-adds the removed fields, but it isn't mentioned in the documentation (and I haven't installed it).
- https://github.com/codingjoe/django-mail-auth/blob/3b9b702b5edaa4913d2eff82503b25a11f881bbf/mailauth/forms.py#L115-L120 explicitly does a case-sensitive search on postgres.

As a fix, I've changed the `get_users()` method on my already-customised `EmailLoginForm`.

I can see some options:
- Mention the need for django-citext on postgres in the documentation.
- Make all email queries use `__iexact`. Small possible performance hit on postgres, but saver.
- I've made some unrelated mistake :-)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.