Skip to content

Commit

Permalink
fix: patch verify otp on test
Browse files Browse the repository at this point in the history
  • Loading branch information
J0 committed Oct 1, 2024
1 parent c112b4b commit 4d4b39d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/api/mfa.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,10 @@ func (a *API) verifyPhoneFactor(w http.ResponseWriter, r *http.Request, params *
var otpCode string
var shouldReEncrypt bool
if config.Sms.IsTwilioVerifyProvider() {
smsProvider, _ := sms_provider.GetSmsProvider(*config)
smsProvider, err := sms_provider.GetSmsProvider(*config)
if err != nil {
return internalServerError("Failed to get SMS provider").WithInternalError(err)
}
if err := smsProvider.VerifyOTP(factor.Phone.String(), params.Code); err != nil {
return forbiddenError(ErrorCodeOTPExpired, "Token has expired or is invalid").WithInternalError(err)
}
Expand Down
3 changes: 3 additions & 0 deletions internal/api/phone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ func (t *TestSmsProvider) SendMessage(phone, message, channel, otp string) (stri
t.SentMessages += 1
return "", nil
}
func (t *TestSmsProvider) VerifyOTP(phone, otp string) error {
return nil
}

func TestPhone(t *testing.T) {
api, config, err := setupAPIForTest()
Expand Down

0 comments on commit 4d4b39d

Please sign in to comment.