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
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()

View file

@ -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)

View file

@ -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()