diff --git a/backend/internal/services/auth.go b/backend/internal/services/auth.go index 6f7eafd..5775b67 100644 --- a/backend/internal/services/auth.go +++ b/backend/internal/services/auth.go @@ -348,6 +348,14 @@ func (a *authServiceImpl) RegistrationBegin(request models.RegistrationBeginRequ a.log.Error( "Failed to commit transaction", zap.Error(err)) + + redisErr := a.redis.Del(context.TODO(), fmt.Sprintf("email::%s::registration_in_progress", request.Email)) + if redisErr != nil { + a.log.Error( + "Failed to delete cooldown redis key while rolling back RegistrationBegin", + zap.Error(redisErr.Err())) + } + return false, errs.ErrServerError } @@ -808,6 +816,14 @@ func (a *authServiceImpl) PasswordResetBegin(request models.PasswordResetBeginRe a.log.Error( "Failed to commit transaction", zap.Error(err)) + + redisErr := a.redis.Del(context.TODO(), fmt.Sprintf("email::%s::reset_cooldown", request.Email)) + if redisErr != nil { + a.log.Error( + "Failed to delete cooldown redis key while rolling back PasswordResetBegin", + zap.Error(redisErr.Err())) + } + return false, errs.ErrServerError } @@ -904,6 +920,7 @@ func (a *authServiceImpl) PasswordResetComplete(request models.PasswordResetComp } } + // FIXME: grab client info session, err = db.TXQueries.CreateSession(db.CTX, database.CreateSessionParams{ UserID: user.ID, Name: utils.NewPointer("First device"), @@ -947,6 +964,7 @@ func (a *authServiceImpl) PasswordResetComplete(request models.PasswordResetComp return &response, nil } +// XXX: Mechanism for loging out existing sessions currently does not exist func (a *authServiceImpl) ChangePassword(request models.ChangePasswordRequest, uinfo dto.ClientInfo) (bool, error) { var err error @@ -981,7 +999,7 @@ func (a *authServiceImpl) ChangePassword(request models.ChangePasswordRequest, u return false, errs.ErrServerError } - err = db.TXlessQueries.UpdateLoginInformationByUsername(db.CTX, database.UpdateLoginInformationByUsernameParams{ + err = db.TXQueries.UpdateLoginInformationByUsername(db.CTX, database.UpdateLoginInformationByUsernameParams{ Username: uinfo.Username, PasswordHash: newPasswordHash, }); if err != nil {