chore: reset two-factor authentication after changing admin credentials (#3029)

* chore: add `resetTwoFactor` argument for main.go

fixes #3025

* chore: reset two-factor authentication after changing admin credentials

* chore: reset two-factor authentication after changing admin credentials

---------

Co-authored-by: somebodywashere <68244480+somebodywashere@users.noreply.github.com>
Co-authored-by: Sanaei <ho3ein.sanaei@gmail.com>
This commit is contained in:
Shishkevich D.
2025-07-02 16:25:25 +07:00
committed by GitHub
parent f3d0b92e4a
commit 5d11e6e13f
19 changed files with 104 additions and 23 deletions
+10
View File
@@ -79,6 +79,16 @@ func (s *UserService) UpdateUser(id int, username string, password string) error
return err
}
twoFactorEnable, err := s.settingService.GetTwoFactorEnable()
if err != nil {
return err
}
if twoFactorEnable {
s.settingService.SetTwoFactorEnable(false)
s.settingService.SetTwoFactorToken("")
}
return db.Model(model.User{}).
Where("id = ?", id).
Updates(map[string]any{"username": username, "password": hashedPassword}).