From 15cb3fb5bfbe229c5f8b93fb99aee96c1ca6cc4b Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 22 Oct 2011 16:38:33 +0200 Subject: [PATCH] longer emails, longer passwords, longer reset codes --- pandora/monkey_patch/models.py | 17 +++++++++++------ pandora/user/models.py | 2 +- pandora/user/views.py | 3 ++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/pandora/monkey_patch/models.py b/pandora/monkey_patch/models.py index 95e08244..13c5130c 100644 --- a/pandora/monkey_patch/models.py +++ b/pandora/monkey_patch/models.py @@ -5,13 +5,18 @@ from django.core.validators import MaxLengthValidator import app.models app.models.load_config() -NEW_USERNAME_LENGTH = 255 +NEW_LENGTH = { + 'username': 255, + 'email': 255, + 'password': 255, +} def monkey_patch_username(): - username = User._meta.get_field("username") - username.max_length = NEW_USERNAME_LENGTH - for v in username.validators: - if isinstance(v, MaxLengthValidator): - v.limit_value = NEW_USERNAME_LENGTH + for field in NEW_LENGTH: + f= User._meta.get_field(field) + f.max_length = NEW_LENGTH[field] + for v in f.validators: + if isinstance(v, MaxLengthValidator): + v.limit_value = NEW_LENGTH[field] monkey_patch_username() diff --git a/pandora/user/models.py b/pandora/user/models.py index 1c09cc32..2216f118 100644 --- a/pandora/user/models.py +++ b/pandora/user/models.py @@ -16,7 +16,7 @@ from itemlist.models import List, Position class UserProfile(models.Model): - reset_code = models.TextField(blank=True, null=True, unique=True) + reset_code = models.CharField(max_length=255, blank=True, null=True, unique=True) user = models.ForeignKey(User, unique=True, related_name='profile') level = models.IntegerField(default=1) diff --git a/pandora/user/views.py b/pandora/user/views.py index a5bd5f97..bb4f0481 100644 --- a/pandora/user/views.py +++ b/pandora/user/views.py @@ -268,7 +268,8 @@ def requestToken(request): user = None if user: while True: - code = ox.to26(random.randint(32768, 1048575)) + code = ox.to26(random.randint(ox.from26('BAAAAAAAAAAAAAAA'), + ox.from26('BAAAAAAAAAAAAAAAA'))) if models.UserProfile.objects.filter(reset_code=code).count() == 0: break user_profile = user.get_profile()