expephalon/core/models/auth.py

20 lines
729 B
Python
Raw Normal View History

2020-05-23 11:59:53 +00:00
from django.db.models import Model, ForeignKey, CharField, DateTimeField, UUIDField, CASCADE, BooleanField, IPAddressField
from django.contrib.auth import get_user_model
from uuid import uuid4
class LoginSession(Model):
uuid = UUIDField(default=uuid4, primary_key=True)
user = ForeignKey(get_user_model(), CASCADE)
creation = DateTimeField(auto_now_add=True)
class PWResetToken(Model):
token = UUIDField(default=uuid4, primary_key=True)
user = ForeignKey(get_user_model(), CASCADE)
2020-05-23 11:59:53 +00:00
creation = DateTimeField(auto_now_add=True)
class LoginLog(Model):
user = ForeignKey(get_user_model(), CASCADE)
ip = IPAddressField()
success = BooleanField()
timestamp = DateTimeField(auto_now_add=True)