diff options
| author | Shishkevich D. <135337715+shishkevichd@users.noreply.github.com> | 2025-07-02 12:25:25 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-02 12:25:25 +0300 |
| commit | 5d11e6e13f7254a72874dabee6c1cf4e81f5ec52 (patch) | |
| tree | 3e255de35ef4f9f4cb79daabaa7a696f10263dc1 /web/service/user.go | |
| parent | f3d0b92e4ab2737f96fea3d0f567fdc040c21acb (diff) | |
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>
Diffstat (limited to 'web/service/user.go')
| -rw-r--r-- | web/service/user.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/web/service/user.go b/web/service/user.go index f0b04f52..ff5b8531 100644 --- a/web/service/user.go +++ b/web/service/user.go @@ -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}). |
