2020-05-23 13:30:21 +00:00
|
|
|
from django.db.models import Model, ForeignKey, CharField, DateTimeField, UUIDField, CASCADE, SET_NULL, BooleanField, GenericIPAddressField
|
2020-04-15 20:19:03 +00:00
|
|
|
from django.contrib.auth import get_user_model
|
|
|
|
|
2020-05-23 16:48:37 +00:00
|
|
|
from dbsettings.functions import getValue
|
|
|
|
|
2020-06-01 16:29:22 +00:00
|
|
|
from core.fields.base import LongCharField
|
|
|
|
|
2020-04-15 20:19:03 +00:00
|
|
|
from uuid import uuid4
|
2020-05-23 16:48:37 +00:00
|
|
|
from datetime import timedelta
|
2020-04-15 20:19:03 +00:00
|
|
|
|
|
|
|
class LoginSession(Model):
|
|
|
|
uuid = UUIDField(default=uuid4, primary_key=True)
|
|
|
|
user = ForeignKey(get_user_model(), CASCADE)
|
2020-04-18 13:02:41 +00:00
|
|
|
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):
|
2020-05-23 13:30:21 +00:00
|
|
|
user = ForeignKey(get_user_model(), SET_NULL, null=True)
|
|
|
|
ip = GenericIPAddressField()
|
2020-05-23 11:59:53 +00:00
|
|
|
success = BooleanField()
|
2020-05-23 16:48:37 +00:00
|
|
|
timestamp = DateTimeField(auto_now_add=True)
|
|
|
|
|
|
|
|
class IPLimit(Model):
|
|
|
|
ip = GenericIPAddressField()
|
2020-06-01 16:29:22 +00:00
|
|
|
end = DateTimeField()
|
|
|
|
reason = LongCharField(null=True, blank=True)
|