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:
parent
4420666f2b
commit
167d5a0903
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user