Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion internal/api/mfa.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand All @@ -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)
}
}
Expand Down
3 changes: 2 additions & 1 deletion internal/api/phone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down
1 change: 1 addition & 0 deletions internal/hooks/v0hooks/v0hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down