code refactor

This commit is contained in:
MaysWind
2020-12-05 20:11:46 +08:00
parent a147191804
commit 611e10e846
5 changed files with 41 additions and 25 deletions
+4 -2
View File
@@ -108,11 +108,13 @@ func (s *TwoFactorAuthorizationService) DeleteTwoFactorSetting(uid int64) error
return s.UserDB().DoTransaction(func(sess *xorm.Session) error {
deletedRows, err := sess.Where("uid=?", uid).Delete(&models.TwoFactor{})
if deletedRows < 1 {
if err != nil {
return err
} else if deletedRows < 1 {
return errs.ErrTwoFactorIsNotEnabled
}
return err
return nil
})
}