Skip to content

Conversation

@radon-at-beeper
Copy link
Collaborator

@radon-at-beeper radon-at-beeper commented Jan 26, 2026

  • add phonenumbers library
  • use it regexp to check if the user tried to login to messenger with a phone number, and error out if so
    • instead of checking whether the user gave a phone number, check whether they gave an email (must contain at-sign) or username (rules: only supports ASCII alphanumeric and periods, must have at least one letter)
  • set machine id to an empty string to match native client behavior on new device
  • add comments explaining how we would get phone number login to work if we want to

@radon-at-beeper radon-at-beeper requested a review from tulir January 27, 2026 16:23
return &b
}

var usernameOrEmailRegexp = regexp.MustCompile(`^([a-zA-Z0-9.]+[a-zA-Z][a-zA-Z0-9.]*|[a-zA-Z0-9.]*[a-zA-Z][a-zA-Z0-9.]+|.+@.+)$`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instagram seems to allow 1 character usernames as well as underscores, so the username part should probably just be [a-zA-Z0-9._]*[a-zA-Z][a-zA-Z0-9._]*? (so no +* and *+ as separate options)

1 number/dot/underscore usernames don't exist fortunately

Suggested change
var usernameOrEmailRegexp = regexp.MustCompile(`^([a-zA-Z0-9.]+[a-zA-Z][a-zA-Z0-9.]*|[a-zA-Z0-9.]*[a-zA-Z][a-zA-Z0-9.]+|.+@.+)$`)
var usernameOrEmailRegexp = regexp.MustCompile(`^([a-zA-Z0-9._]*[a-zA-Z][a-zA-Z0-9._]*|.+@.+)$`)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait I'm dumb this is messenger only, anyway, probably no need for the 2 cases?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(actually in theory we might want this for instagram in the future? they use the same bloks stuff, not sure how reusable the code is though)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess there is no harm doing it the way you suggested, it is not a valid username but we only need this regex to filter out phone numbers. Making a tweak

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's called the "definitely not a phone number" regexp now, and I just check if it contains at least an at-sign or letter

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah that regex is much simpler and should do the trick

Copy link
Member

@tulir tulir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine other than the potential minor tweak to the regex

@radon-at-beeper radon-at-beeper enabled auto-merge (squash) January 27, 2026 16:37
@radon-at-beeper radon-at-beeper merged commit d253251 into main Jan 27, 2026
10 of 11 checks passed
@radon-at-beeper radon-at-beeper deleted the rr-phone-numbers-nope branch January 27, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants