🐛 Trying to fix nats: subject does not match consumer
This commit is contained in:
parent
144219f0aa
commit
e4ba72725e
@ -72,7 +72,7 @@ func InitializeToNexus() error {
|
||||
Name: "OTPs",
|
||||
Subjects: []string{FactorOtpPrefix + ">"},
|
||||
Storage: nats.MemoryStorage,
|
||||
MaxAge: 5 * time.Minute,
|
||||
MaxAge: 30 * time.Minute,
|
||||
}
|
||||
_, err = Jt.AddStream(jetstreamCfg)
|
||||
if err != nil && !errors.Is(err, nats.ErrStreamNameAlreadyInUse) {
|
||||
|
@ -119,11 +119,13 @@ func CheckFactor(factor models.AuthFactor, code string) error {
|
||||
)
|
||||
case models.EmailPasswordFactor:
|
||||
identifier := fmt.Sprintf("%s%d", gap.FactorOtpPrefix, factor.ID)
|
||||
sub, err := gap.Jt.PullSubscribe(identifier, "otp_validator")
|
||||
sub, err := gap.Jt.PullSubscribe(identifier, "otp_validator", nats.BindStream("OTPs"))
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error subscribing to subject when validating factor code...")
|
||||
return fmt.Errorf("error subscribing to subject: %v", err)
|
||||
}
|
||||
// ChatGPT said the subscription will be reused, so we don't need to unsubscribe
|
||||
// defer sub.Unsubscribe()
|
||||
|
||||
msgs, err := sub.Fetch(1, nats.MaxWait(3*time.Second))
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user