Skip to content

Commit bfe4d98

Browse files
J0kangmingtay
andauthored
fix: do call send sms hook when SMS autoconfirm is enabled (#1562)
## What kind of change does this PR introduce? Small quirk discovered while testing - it currently looks like when SMS Autoconfirm is set ``` GOTRUE_SMS_AUTOCONFIRM="true" ``` and an OTP request is made: ``` curl -X POST http://localhost:9999/otp -H "Content-Type: application/json" -d '{"phone": "<phone>"}' ``` an OTP is still sent. There's a substantial number projects (see internal for exact number) using this so probably will preserve this behaviour. This affects the edge case where `SMS_AUTOCONFIRM` is enabled but the Hook returns an error which may leave the developer puzzled since one might expect an SMS not to be sent with autoconfirm similar to `MAILER_AUTOCONFIRM` Before: - Enable Send SMS and autoconfirm, make a request with faulty URI - request should fail After: - Enable Send SMS and autoconfirm, make a request - message is sent as per current behaviour --------- Co-authored-by: Kang Ming <[email protected]>
1 parent 434a59a commit bfe4d98

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

internal/api/phone.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ func (a *API) sendPhoneConfirmation(ctx context.Context, r *http.Request, tx *st
9595
if err != nil {
9696
return "", err
9797
}
98-
if config.Hook.SendSMS.Enabled {
98+
// Hook should only be called if SMS autoconfirm is disabled
99+
if !config.Sms.Autoconfirm && config.Hook.SendSMS.Enabled {
99100
input := hooks.SendSMSInput{
100101
User: user,
101102
SMS: hooks.SMS{

0 commit comments

Comments
 (0)