feat: new RollbackOnError method added for transactional db helper and integrated into auth service

This commit is contained in:
2025-07-13 15:57:34 +03:00
parent a3bebd89be
commit 65ea47dbb6
2 changed files with 29 additions and 21 deletions

View File

@@ -66,7 +66,7 @@ func (a *authServiceImpl) RegistrationBegin(request models.RegistrationBeginRequ
var err error
helper, db, _ := database.NewDbHelperTransaction(a.dbctx)
defer helper.Rollback()
defer helper.RollbackOnError(err)
// TODO: check occupation with redis
@@ -199,7 +199,7 @@ func (a *authServiceImpl) RegistrationComplete(request models.RegistrationComple
var err error
helper, db, _ := database.NewDbHelperTransaction(a.dbctx)
defer helper.Rollback()
defer helper.RollbackOnError(err)
user, err = db.TXQueries.GetUserByUsername(db.CTX, request.Username)
@@ -334,11 +334,10 @@ func (a *authServiceImpl) RegistrationComplete(request models.RegistrationComple
func (a *authServiceImpl) Login(request models.LoginRequest) (*models.LoginResponse, error) {
var userRow database.GetValidUserByLoginCredentialsRow
var session database.Session
var err error
helper, db, _ := database.NewDbHelperTransaction(a.dbctx)
defer helper.Rollback()
var err error
defer helper.RollbackOnError(err)
userRow, err = db.TXQueries.GetValidUserByLoginCredentials(db.CTX, database.GetValidUserByLoginCredentialsParams{
Username: request.Username,
@@ -417,7 +416,7 @@ func (a *authServiceImpl) PasswordResetBegin(request models.PasswordResetBeginRe
var err error
helper, db, err := database.NewDbHelperTransaction(a.dbctx)
defer helper.Rollback()
defer helper.RollbackOnError(err)
ctx := context.TODO()