1
0
mirror of https://github.com/volatiletech/authboss.git synced 2025-01-10 04:17:59 +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
import (
"context"
"crypto/rand"
"crypto/subtle"
"io"
@ -76,7 +77,7 @@ type SMSNumberProvider interface {
// SMSSender sends SMS messages to a phone number
type SMSSender interface {
Send(number, text string) error
Send(ctx context.Context, number, text string) error
}
// 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)
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)
return err
}

View File

@ -15,7 +15,7 @@ import (
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)
return nil
}