🐛 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",
|
Name: "OTPs",
|
||||||
Subjects: []string{FactorOtpPrefix + ">"},
|
Subjects: []string{FactorOtpPrefix + ">"},
|
||||||
Storage: nats.MemoryStorage,
|
Storage: nats.MemoryStorage,
|
||||||
MaxAge: 5 * time.Minute,
|
MaxAge: 30 * time.Minute,
|
||||||
}
|
}
|
||||||
_, err = Jt.AddStream(jetstreamCfg)
|
_, err = Jt.AddStream(jetstreamCfg)
|
||||||
if err != nil && !errors.Is(err, nats.ErrStreamNameAlreadyInUse) {
|
if err != nil && !errors.Is(err, nats.ErrStreamNameAlreadyInUse) {
|
||||||
|
@ -119,11 +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_validator")
|
sub, err := gap.Jt.PullSubscribe(identifier, "otp_validator", nats.BindStream("OTPs"))
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
// 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))
|
msgs, err := sub.Fetch(1, nats.MaxWait(3*time.Second))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user