straight55b / app-engine-patch

Automatically exported from code.google.com/p/app-engine-patch
0 stars 0 forks source link

Using user.nickname() as username in hybrid model risky #120

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
You end up with alot of cases where you could create a pure django user with a 
username that 
would then collide with a google user's nickname, making there registration 
impossible. Seems 
like it makes more sense to use the user.email() as the username, as chance of 
collision is far 
lower.

class User(GoogleUserTraits):
    """User class that provides support for Django and Google Accounts."""
    user = db.UserProperty()
    username = db.StringProperty(required=True, verbose_name=_('username'))
    email = db.EmailProperty(verbose_name=_('e-mail address'))
    first_name = db.StringProperty(verbose_name=_('first name'))
    last_name = db.StringProperty(verbose_name=_('last name'))

    class Meta:
        verbose_name = _('user')
        verbose_name_plural = _('users')

    @classmethod
    def create_djangouser_for_user(cls, user):
        #return cls(user=user, email=user.email(), username=user.nickname())
        return cls(user=user, email=user.email(), username=user.email())

Original issue reported on code.google.com by fuma...@gmail.com on 2 Apr 2009 at 1:29

GoogleCodeExporter commented 9 years ago
Fixed in repo.

Original comment by wkornew...@gmail.com on 2 Apr 2009 at 9:04