Giter VIP home page Giter VIP logo

Comments (8)

pawl-bb avatar pawl-bb commented on June 22, 2024 1

Django-improved-user argues that it's better to store the e-mail addresses in a case sensitive field and use case-insensitive queries to filter for a match: https://django-improved-user.readthedocs.io/en/latest/email_warning.html

@aidanlister's example seems to cover that, but he might also need to have an index on lower(email::text) to prevent duplicates? Without the unique index, another user might be able to create an uppercase version of an existing e-mail and have it match.

Although the first part of the e-mail is supposed to be case sensitive (according to RFC 5321), I don't know of any e-mail providers that actually do that. So maybe it doesn't matter?

from django-authtools.

gavinwahl avatar gavinwahl commented on June 22, 2024

A functional index on UPPER(email) would be the ideal solution on postgres, but we'd have to use email__iexact everywhere, and lookups by email wouldn't be indexed at all on mysql.

from django-authtools.

pipermerriam avatar pipermerriam commented on June 22, 2024

Maybe we could do get by with just dbindex=True and do our normalization outside of the database. Something similar to what BaseManager does here

Is there a problem just calling .lower() or .upper() on the address part of the email?

from django-authtools.

rockymeza avatar rockymeza commented on June 22, 2024

https://github.com/fusionbox/django-authtools/blob/master/authtools/models.py#L14

Is there anything we can do?

from django-authtools.

chris-erickson avatar chris-erickson commented on June 22, 2024

This is a bit of a trouble spot for users entering emails in interesting ways. 👍 for any fix..

from django-authtools.

aidanlister avatar aidanlister commented on June 22, 2024

#31 won't work for anyone on Postgres.

It simply does a .lower() on the incoming login, but not the database User.get operation. So if there's a capitalised email in the database it's impossible to login.

from django-authtools.

aidanlister avatar aidanlister commented on June 22, 2024

Here's a better way:

class AccountManager(models.Manager):
    def get_by_natural_key(self, username):
        field_name = f'{self.model.USERNAME_FIELD}__iexact'
        return self.get(**{field_name: username})

Set this on your custom user model.

from django-authtools.

gavinwahl avatar gavinwahl commented on June 22, 2024

Isn't that handled by CaseInsensitiveEmailBackendMixin?

from django-authtools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.