dkforest

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

commit 10f33f154cf092ceb4ef9012d30c12751c0ca003
parent 6e6b88e240dd37d18d339fcd8f0dc8a33315dc25
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Fri,  9 Feb 2024 18:48:02 -0800

cleanup code

Diffstat:
Mpkg/database/tableUsers.go | 4++++
Mpkg/web/handlers/handlers.go | 3+--
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/pkg/database/tableUsers.go b/pkg/database/tableUsers.go @@ -367,6 +367,10 @@ func (u *User) DisableTotp2FA(db *DkfDB) { db.db.Model(u).Select("TwoFactorSecret", "TwoFactorRecovery").Updates(User{TwoFactorSecret: "", TwoFactorRecovery: ""}) } +func (u *User) DisableGpg2FA(db *DkfDB) { + db.db.Model(u).Select("GpgTwoFactorEnabled").Updates(User{GpgTwoFactorEnabled: false}) +} + func (u *User) SetAgePublicKey(db *DkfDB, agePublicKey string) { db.db.Model(u).Select("AgePublicKey").Updates(User{AgePublicKey: agePublicKey}) } diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go @@ -361,8 +361,7 @@ func GpgTwoFactorAuthenticationToggleHandler(c echo.Context) error { // Disable if authUser.GpgTwoFactorEnabled { - authUser.GpgTwoFactorEnabled = false - authUser.DoSave(db) + authUser.DisableGpg2FA(db) db.CreateSecurityLog(authUser.ID, database.Gpg2faDisabledSecurityLog) return c.Render(http.StatusOK, "flash", FlashResponse{"GPG Two-factor authentication disabled", "/settings/account", "alert-success"}) }