This commit is contained in:
MaysWind
2020-11-08 20:02:59 +08:00
parent 234b5a7465
commit 180ae7cb72
5 changed files with 14 additions and 14 deletions
+5 -5
View File
@@ -94,7 +94,7 @@ func (s *TwoFactorAuthorizationService) CreateTwoFactorSetting(twoFactor *models
twoFactor.CreatedUnixTime = time.Now().Unix()
return s.UserDB().DoTranscation(func(sess *xorm.Session) error {
return s.UserDB().DoTransaction(func(sess *xorm.Session) error {
_, err := sess.Insert(twoFactor)
return err
})
@@ -105,7 +105,7 @@ func (s *TwoFactorAuthorizationService) DeleteTwoFactorSetting(uid int64) error
return errs.ErrUserIdInvalid
}
return s.UserDB().DoTranscation(func(sess *xorm.Session) error {
return s.UserDB().DoTransaction(func(sess *xorm.Session) error {
deletedRows, err := sess.Where("uid=?", uid).Delete(&models.TwoFactor{})
if deletedRows < 1 {
@@ -138,7 +138,7 @@ func (s *TwoFactorAuthorizationService) GetAndUseUserTwoFactorRecoveryCode(uid i
return errs.ErrTwoFactorRecoveryCodeNotExist
}
return s.UserDB().DoTranscation(func(sess *xorm.Session) error {
return s.UserDB().DoTransaction(func(sess *xorm.Session) error {
_, err := sess.Cols("used", "used_unix_time").Where("uid=? AND recovery_code=?", uid, recoveryCode).Update(&models.TwoFactorRecoveryCode{Used: true, UsedUnixTime: time.Now().Unix()})
return err
})
@@ -172,7 +172,7 @@ func (s *TwoFactorAuthorizationService) CreateTwoFactorRecoveryCodes(uid int64,
}
}
return s.UserDB().DoTranscation(func(sess *xorm.Session) error {
return s.UserDB().DoTransaction(func(sess *xorm.Session) error {
_, err := sess.Where("uid=?", uid).Delete(&models.TwoFactorRecoveryCode{})
if err != nil {
@@ -197,7 +197,7 @@ func (s *TwoFactorAuthorizationService) DeleteTwoFactorRecoveryCodes(uid int64)
return errs.ErrUserIdInvalid
}
return s.UserDB().DoTranscation(func(sess *xorm.Session) error {
return s.UserDB().DoTransaction(func(sess *xorm.Session) error {
_, err := sess.Where("uid=?", uid).Delete(&models.TwoFactorRecoveryCode{})
return err
})