remarkbox/remarkbox/lib/sudo.py
russell@unturf.com 0667917318 Add sudo OTP verification for destructive operations.
Gate superuser promote/demote, API node deletion, and account
deletion behind an 8-digit email OTP confirmation step.
2026-02-05 16:11:50 -05:00

14 lines
505 B
Python

from remarkbox.models.sudo_otp import create_sudo_otp
from remarkbox.lib.mail import send_sudo_otp_email
def request_sudo_otp(request, action_key, action_description):
"""Generate a sudo OTP code, email it to the current user, and return the code."""
code = create_sudo_otp(
request.dbsession,
action_key,
action_description,
client_ip=str(request.client_addr),
)
send_sudo_otp_email(request, request.user.email, action_description, code)
return code