Add user post deletion

Users can delete their posts as long as they don't clear their cookies,
and as long as server-side user sessions are persistent.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-07-13 21:28:07 -07:00
parent 96e8b7752f
commit a4f00e6242
5 changed files with 39 additions and 2 deletions

View File

@@ -1,6 +1,9 @@
from typing import Optional, TYPE_CHECKING
from django.utils import timezone
from django.conf import settings
import ipaddress
import random
import string
from board.models import Ban, RangeBan
@@ -45,3 +48,11 @@ def is_banned(ip: str, board: Optional["Board"]) -> bool:
return bool(active)
else:
return False
def generate_user_token() -> str:
"""
Generates a non-secure user token.
User tokens need not be secure so this is a simple implementation.
"""
return "".join(random.choices(string.ascii_letters, k=settings.USER_TOKEN_LENGTH))