dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 0ae56308f4b80b5052e52731232cf4bcbf52eb39
parent 10f33f154cf092ceb4ef9012d30c12751c0ca003
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Fri,  9 Feb 2024 18:57:16 -0800

admin can disable 2fa

Diffstat:
Mpkg/web/handlers/admin.go | 4++++
Mpkg/web/public/views/pages/admin/user-edit.gohtml | 5+++++
2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/pkg/web/handlers/admin.go b/pkg/web/handlers/admin.go @@ -640,6 +640,10 @@ func AdminEditUserHandler(c echo.Context) error { if formName == "reset_login_attempts" { user.ResetLoginAttempts(db) return c.Redirect(http.StatusFound, "/admin/users/"+userID.String()+"/edit") + } else if formName == "disable_2fa" { + user.DisableTotp2FA(db) + user.DisableGpg2FA(db) + return c.Redirect(http.StatusFound, "/admin/users/"+userID.String()+"/edit") } else if formName == "reset_tutorial" { user.ResetTutorial(db) return c.Redirect(http.StatusFound, "/admin/users/"+userID.String()+"/edit") diff --git a/pkg/web/public/views/pages/admin/user-edit.gohtml b/pkg/web/public/views/pages/admin/user-edit.gohtml @@ -210,6 +210,11 @@ <input type="submit" class="btn btn-secondary" value="Reset tutorial ({{ .Data.ChatTutorial }})" /> </form> +<form method="post" class="d-inline"> + <input type="hidden" name="csrf" value="{{ .CSRF }}" /> + <input type="hidden" name="formName" value="disable_2fa" /> + <input type="submit" class="btn btn-secondary" value="Disable 2fa ({{ if or .Data.User.GpgTwoFactorEnabled (ne .Data.User.TwoFactorSecret "") }}on{{ else }}off{{ end }})" /> +</form> <form method="post" class="d-inline"> <input type="hidden" name="csrf" value="{{ .CSRF }}" />