You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

32 lines
1.1 KiB

from django.db import models
from django.contrib.auth.hashers import make_password
from django.contrib.auth.models import User
# Basic DB to correlate tokens, users and creation time
class ResetToken(models.Model):
# users wouldn't use usernames >100 chars
user = models.CharField(max_length=100)
# Not so sure about tokens, better make it big
# should be <100, but big usernames make bigger tokens
# if I read that correctly
token = models.CharField(max_length=255)
# creation time in epoch (UTC)
# BigInt just so we are save for the next few decades ;)
creation = models.BigIntegerField()
def get_validation_slug():
return make_password(None)
class UserAccountValidationDetail(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
VALIDATED_CHOICES = ((0, 'Not validated'), (1, 'Validated'))
validated = models.IntegerField(choices=VALIDATED_CHOICES, default=0)
validation_slug = models.CharField(
db_index=True, unique=True, max_length=50,
default=get_validation_slug
)
date_validation_started = models.DateTimeField(auto_now_add=True)