Preparing for login rate limiting

This commit is contained in:
Kumi 2020-05-23 13:59:53 +02:00
parent e924e18234
commit 3ba7c238cc
2 changed files with 12 additions and 3 deletions

View file

@ -9,3 +9,6 @@ def generate_pwreset_mail(user, token):
link = reltoabs(reverse("pwreset", kwargs={"pk": str(token.token)})) link = reltoabs(reverse("pwreset", kwargs={"pk": str(token.token)}))
template = get_template("backend/auth/pwreset", first_name=user.first_name, link=link, sitename=getValue("core.title", "Expephalon")) template = get_template("backend/auth/pwreset", first_name=user.first_name, link=link, sitename=getValue("core.title", "Expephalon"))
return template return template
def login_fail(user):
pass

View file

@ -1,4 +1,4 @@
from django.db.models import Model, ForeignKey, CharField, DateTimeField, UUIDField, CASCADE from django.db.models import Model, ForeignKey, CharField, DateTimeField, UUIDField, CASCADE, BooleanField, IPAddressField
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from uuid import uuid4 from uuid import uuid4
@ -12,3 +12,9 @@ class PWResetToken(Model):
token = UUIDField(default=uuid4, primary_key=True) token = UUIDField(default=uuid4, primary_key=True)
user = ForeignKey(get_user_model(), CASCADE) user = ForeignKey(get_user_model(), CASCADE)
creation = DateTimeField(auto_now_add=True) 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)