tjdests/tjdests/apps/authentication/decorators.py
2022-03-26 10:13:51 -05:00

20 lines
481 B
Python

import functools
from django.http import HttpRequest
from django.shortcuts import redirect
def require_accept_tos(func):
@functools.wraps(func)
def wrapper(request: HttpRequest, *args, **kwargs):
if (
request.user.is_authenticated
and not request.user.accepted_terms
and not request.user.is_banned
):
return redirect("authentication:tos")
return func(request, *args, **kwargs)
return wrapper