diff --git a/internal/api/mfa.go b/internal/api/mfa.go index a1e1de0bf..16d0df3a6 100644 --- a/internal/api/mfa.go +++ b/internal/api/mfa.go @@ -409,12 +409,15 @@ func (a *API) challengePhoneFactor(w http.ResponseWriter, r *http.Request) error return apierrors.NewInternalServerError("error generating sms template").WithInternalError(err) } + phone := factor.Phone.String() + if config.Hook.SendSMS.Enabled { input := v0hooks.SendSMSInput{ User: user, SMS: v0hooks.SMS{ OTP: otp, SMSType: "mfa", + Phone: phone, }, } output := v0hooks.SendSMSOutput{} @@ -428,7 +431,7 @@ func (a *API) challengePhoneFactor(w http.ResponseWriter, r *http.Request) error return apierrors.NewInternalServerError("Failed to get SMS provider").WithInternalError(err) } // We omit messageID for now, can consider reinstating if there are requests. - if _, err = smsProvider.SendMessage(factor.Phone.String(), message, channel, otp); err != nil { + if _, err = smsProvider.SendMessage(phone, message, channel, otp); err != nil { return apierrors.NewInternalServerError("error sending message").WithInternalError(err) } } diff --git a/internal/api/phone.go b/internal/api/phone.go index 9a8662dbb..ab21bf6cd 100644 --- a/internal/api/phone.go +++ b/internal/api/phone.go @@ -98,7 +98,8 @@ func (a *API) sendPhoneConfirmation(r *http.Request, tx *storage.Connection, use input := v0hooks.SendSMSInput{ User: user, SMS: v0hooks.SMS{ - OTP: otp, + OTP: otp, + Phone: phone, }, } output := v0hooks.SendSMSOutput{} diff --git a/internal/hooks/v0hooks/v0hooks.go b/internal/hooks/v0hooks/v0hooks.go index 21675594a..ff7d57aa4 100644 --- a/internal/hooks/v0hooks/v0hooks.go +++ b/internal/hooks/v0hooks/v0hooks.go @@ -95,6 +95,7 @@ type AfterUserCreatedOutput struct{} type SMS struct { OTP string `json:"otp,omitempty"` SMSType string `json:"sms_type,omitempty"` + Phone string `json:"phone,omitempty"` } // AccessTokenClaims is a struct thats used for JWT claims