From a3bebd89be9a502560d9c427273013111d46a4d2 Mon Sep 17 00:00:00 2001 From: Nikolai Papin Date: Sun, 13 Jul 2025 02:18:46 +0300 Subject: [PATCH] chore: todo comments; fix: txless creation of confirmation code in passwordresetbegin --- backend/internal/services/auth.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/internal/services/auth.go b/backend/internal/services/auth.go index 15e0d3b..425ce08 100644 --- a/backend/internal/services/auth.go +++ b/backend/internal/services/auth.go @@ -68,6 +68,8 @@ func (a *authServiceImpl) RegistrationBegin(request models.RegistrationBeginRequ helper, db, _ := database.NewDbHelperTransaction(a.dbctx) defer helper.Rollback() + // TODO: check occupation with redis + if occupationStatus, err = db.TXQueries.CheckUserRegistrationAvailability(db.CTX, database.CheckUserRegistrationAvailabilityParams{ Email: request.Email, Username: request.Username, @@ -89,6 +91,7 @@ func (a *authServiceImpl) RegistrationBegin(request models.RegistrationBeginRequ } else if occupationStatus.EmailBusy { // Falsely confirm in order to avoid disclosing registered email addresses + // TODO: save this email into redis a.log.Warn( "Attempted registration for a taken email", zap.String("email", request.Email), @@ -176,7 +179,7 @@ func (a *authServiceImpl) RegistrationBegin(request models.RegistrationBeginRequ } else { a.log.Debug( - "Declated registration code for a new user. Enable SMTP in the config to disable this message", + "Declared registration code for a new user. Enable SMTP in the config to disable this message", zap.String("username", user.Username), zap.String("code", generatedCode)) } @@ -474,7 +477,7 @@ func (a *authServiceImpl) PasswordResetBegin(request models.PasswordResetBeginRe return false, errs.ErrServerError } - if _, err = db.TXlessQueries.CreateConfirmationCode(db.CTX, database.CreateConfirmationCodeParams{ + if _, err = db.TXQueries.CreateConfirmationCode(db.CTX, database.CreateConfirmationCodeParams{ UserID: user.ID, CodeType: int32(enums.PasswordResetCodeType), CodeHash: hashedCode,