1
0
mirror of https://github.com/volatiletech/authboss.git synced 2025-01-26 05:27:33 +02:00

Add context to the sms sender interface

This commit is contained in:
Aaron L 2018-09-03 11:58:24 -07:00
parent 4420666f2b
commit 167d5a0903
2 changed files with 4 additions and 3 deletions

View File

@ -3,6 +3,7 @@
package sms2fa package sms2fa
import ( import (
"context"
"crypto/rand" "crypto/rand"
"crypto/subtle" "crypto/subtle"
"io" "io"
@ -76,7 +77,7 @@ type SMSNumberProvider interface {
// SMSSender sends SMS messages to a phone number // SMSSender sends SMS messages to a phone number
type SMSSender interface { type SMSSender interface {
Send(number, text string) error Send(ctx context.Context, number, text string) error
} }
// SMS implements time based one time passwords // SMS implements time based one time passwords
@ -188,7 +189,7 @@ func (s *SMS) SendCodeToUser(w http.ResponseWriter, r *http.Request, pid, number
authboss.PutSession(w, SessionSMSSecret, code) authboss.PutSession(w, SessionSMSSecret, code)
logger.Infof("sending sms for %s to %s", pid, number) logger.Infof("sending sms for %s to %s", pid, number)
if err := s.Sender.Send(number, code); err != nil { if err := s.Sender.Send(r.Context(), number, code); err != nil {
logger.Infof("failed to send sms for %s to %s: %+v", pid, number, err) logger.Infof("failed to send sms for %s to %s: %+v", pid, number, err)
return err return err
} }

View File

@ -15,7 +15,7 @@ import (
type smsHolderSender string type smsHolderSender string
func (s *smsHolderSender) Send(number, text string) error { func (s *smsHolderSender) Send(ctx context.Context, number, text string) error {
*s = smsHolderSender(text) *s = smsHolderSender(text)
return nil return nil
} }