🐛 Fix nats option durable set more than once

This commit is contained in:
LittleSheep 2025-01-27 15:53:34 +08:00
parent 72d0cbb7be
commit 144219f0aa

View File

@ -119,13 +119,13 @@ func CheckFactor(factor models.AuthFactor, code string) error {
) )
case models.EmailPasswordFactor: case models.EmailPasswordFactor:
identifier := fmt.Sprintf("%s%d", gap.FactorOtpPrefix, factor.ID) identifier := fmt.Sprintf("%s%d", gap.FactorOtpPrefix, factor.ID)
sub, err := gap.Jt.PullSubscribe(identifier, "otp_consumer", nats.Durable("otp_consumer")) sub, err := gap.Jt.PullSubscribe(identifier, "otp_validator")
if err != nil { if err != nil {
log.Error().Err(err).Msg("Error subscribing to subject when validating factor code...") log.Error().Err(err).Msg("Error subscribing to subject when validating factor code...")
return fmt.Errorf("error subscribing to subject: %v", err) return fmt.Errorf("error subscribing to subject: %v", err)
} }
msgs, err := sub.Fetch(1, nats.MaxWait(2*time.Second)) msgs, err := sub.Fetch(1, nats.MaxWait(3*time.Second))
if err != nil { if err != nil {
log.Error().Err(err).Msg("Error fetching message when validating factor code...") log.Error().Err(err).Msg("Error fetching message when validating factor code...")
return fmt.Errorf("error fetching message: %v", err) return fmt.Errorf("error fetching message: %v", err)