ungleich-user/dal/models.py

33 lines
1.1 KiB
Python
Raw Permalink Normal View History

2018-10-15 19:24:53 +00:00
from django.db import models
2019-02-19 23:25:51 +00:00
from django.contrib.auth.hashers import make_password
from django.contrib.auth.models import User
2018-10-15 19:24:53 +00:00
# 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 ;)
2018-10-15 19:24:53 +00:00
creation = models.BigIntegerField()
2019-02-19 23:25:51 +00:00
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)