|
@ -3,6 +3,7 @@ import secrets |
|
|
|
|
|
|
|
|
from django.core.signing import TimestampSigner, SignatureExpired |
|
|
from django.core.signing import TimestampSigner, SignatureExpired |
|
|
from django.shortcuts import redirect, render |
|
|
from django.shortcuts import redirect, render |
|
|
|
|
|
from hc.api.models import TokenBucket |
|
|
from hc.lib import emails |
|
|
from hc.lib import emails |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -25,6 +26,9 @@ def require_sudo_mode(f): |
|
|
if _session_unsign(request, "sudo", 1800) == "active": |
|
|
if _session_unsign(request, "sudo", 1800) == "active": |
|
|
return f(request, *args, **kwds) |
|
|
return f(request, *args, **kwds) |
|
|
|
|
|
|
|
|
|
|
|
if not TokenBucket.authorize_sudo_code(request.user): |
|
|
|
|
|
return render(request, "try_later.html") |
|
|
|
|
|
|
|
|
# has the user submitted a code to enter sudo mode? |
|
|
# has the user submitted a code to enter sudo mode? |
|
|
if "sudo_code" in request.POST: |
|
|
if "sudo_code" in request.POST: |
|
|
ours = _session_unsign(request, "sudo_code", 900) |
|
|
ours = _session_unsign(request, "sudo_code", 900) |
|
|