update enable_totp(request) redirect if totp is already enabled

This commit is contained in:
Trent Palmer 2021-04-19 21:07:15 -07:00
parent 5b99609dc7
commit e65a1026f8

View File

@ -26,6 +26,8 @@ def disable_totp(request):
def enable_totp(request): def enable_totp(request):
if not request.user.is_authenticated: if not request.user.is_authenticated:
return redirect('audio:home') return redirect('audio:home')
if request.user.account.use_totp and request.user.account.totp_key is not None:
return(redirect('accounts:edit_profile'))
qr = get_totp_qr(request.user) qr = get_totp_qr(request.user)
if request.method == "POST": if request.method == "POST":
form = EnableTotpForm(request.POST, instance=request.user.account) form = EnableTotpForm(request.POST, instance=request.user.account)