30 lines
1,016 B
Python
30 lines
1,016 B
Python
from django.db.models import Model, ForeignKey, CharField, DateTimeField, UUIDField, CASCADE, SET_NULL, BooleanField, GenericIPAddressField
|
|
from django.contrib.auth import get_user_model
|
|
|
|
from dbsettings.functions import getValue
|
|
|
|
from core.fields.base import LongCharField
|
|
|
|
from uuid import uuid4
|
|
from datetime import timedelta
|
|
|
|
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)
|
|
creation = DateTimeField(auto_now_add=True)
|
|
|
|
class LoginLog(Model):
|
|
user = ForeignKey(get_user_model(), SET_NULL, null=True)
|
|
ip = GenericIPAddressField()
|
|
success = BooleanField()
|
|
timestamp = DateTimeField(auto_now_add=True)
|
|
|
|
class IPLimit(Model):
|
|
ip = GenericIPAddressField()
|
|
end = DateTimeField()
|
|
reason = LongCharField(null=True, blank=True)
|