longer emails, longer passwords, longer reset codes

This commit is contained in:
j 2011-10-22 16:38:33 +02:00
parent 7738ac2779
commit 15cb3fb5bf
3 changed files with 14 additions and 8 deletions

View file

@ -5,13 +5,18 @@ from django.core.validators import MaxLengthValidator
import app.models import app.models
app.models.load_config() app.models.load_config()
NEW_USERNAME_LENGTH = 255 NEW_LENGTH = {
'username': 255,
'email': 255,
'password': 255,
}
def monkey_patch_username(): def monkey_patch_username():
username = User._meta.get_field("username") for field in NEW_LENGTH:
username.max_length = NEW_USERNAME_LENGTH f= User._meta.get_field(field)
for v in username.validators: f.max_length = NEW_LENGTH[field]
for v in f.validators:
if isinstance(v, MaxLengthValidator): if isinstance(v, MaxLengthValidator):
v.limit_value = NEW_USERNAME_LENGTH v.limit_value = NEW_LENGTH[field]
monkey_patch_username() monkey_patch_username()

View file

@ -16,7 +16,7 @@ from itemlist.models import List, Position
class UserProfile(models.Model): 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') user = models.ForeignKey(User, unique=True, related_name='profile')
level = models.IntegerField(default=1) level = models.IntegerField(default=1)

View file

@ -268,7 +268,8 @@ def requestToken(request):
user = None user = None
if user: if user:
while True: 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: if models.UserProfile.objects.filter(reset_code=code).count() == 0:
break break
user_profile = user.get_profile() user_profile = user.get_profile()