fix(verify): record a login, not a signup, for confirmed phone sign-ins - #2835
Open
sidgaikwad wants to merge 1 commit into
Open
sidgaikwad wants to merge 1 commit into
sidgaikwad wants to merge 1 commit into
Conversation
smsVerify recorded a user_signedup audit event for every sms verification, including existing users whose phone is already confirmed. Each SMS sign-in by an existing user was counted as a new signup. Record login when the phone is already confirmed, as recoverVerify does for confirmed email users. ConfirmPhone still runs in both cases because it also clears the user's one-time tokens. Refs supabase/supabase#37583
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Verifying an SMS code (
POST /verifywithtype: sms) always records auser_signedupaudit event, even when the phone is already confirmed and the user is just signing in. Every SMS sign-in by an existing user therefore shows up as a new signup. Reported in supabase/supabase#37583, where the Auth reports in the Supabase dashboard counted repeat phone sign-ins as sign-ups.The email paths already make this distinction.
recoverVerify, used for magic links and recovery, recordsuser_signeduponly when!user.IsConfirmed(), andloginotherwise.This PR makes
smsVerifydo the same: it recordsloginwhenuser.IsPhoneConfirmed()anduser_signedupotherwise.ConfirmPhonestill runs in both cases, because it also clears the user's one-time tokens. Only the audit action changes.Tests: a new case in
TestVerifyOTPParityPhoneFlows, "sms with a valid code signs a confirmed user in". It mirrors the existing "magiclink with a valid code signs a confirmed user in" case, seeds a confirmed phone, and expectsloginon both the legacy andone_time_tokensstores. The existing "sms with a valid code confirms the phone" case, whose fixture phone is unconfirmed, still expectsuser_signedup.Verified locally (
golang:1.27.0-alpine3.23againstpostgres:15initialized withhack/init_postgres.sql, migrations viago run main.go migrate -c hack/test.env):verify.gochange reverted it fails on both, withexpected Action:"login"andactual Action:"user_signedup".gofmt -lis clean on the changed files, andgo vet ./internal/apipasses.go test ./internal/apirun, the only failure isTestAuth/TestMaybeLoadUserOrSession/Valid_Session_ID_Claim, which fails the same way on unmodifiedmasterin my environment.TestExternalcases that reach real OIDC endpoints also fail intermittently with504there, on both branches.