Code signup lets a disallowed email domain reach the code screen, but no code is ever sent

Summary

With enable_local_logins_via_code on and allowed_email_domains set, signing up with an email whose domain is not on the allowed list takes the visitor to the “check your email, enter the 6-digit code” screen — but no code is ever generated or sent. The visitor is stuck at a dead end with no explanation, and nothing shows up in the admin email logs.

Steps to reproduce

  1. Set allowed_email_domains to a list that does not include the test domain, e.g. qq.com|gmail.com|163.com.
  2. Enable enable_local_logins_via_code and enable_local_logins_via_email.
  3. As a logged-out visitor, open /signup and enter an email with a disallowed domain (e.g. www@imlotso.com).
  4. Submit. The UI advances to the code entry screen saying a 6-digit code was sent.

Actual result

No code is generated, no email is sent, and nothing appears in Admin → Emails → Sent or Skipped. The user waits for a code that will never arrive.

Expected result

The email step should reject the domain up front — the classic password signup flow does this via User.checkEmail, which returns the “email not allowed” error inline. At minimum the code screen should not claim a code was sent when none was.

What I found in the code (self-hosted, version 2026.12.0-latest, revision b69b9c02)

  • app/services/email_login_code/request.rb: deliverable? returns false when EmailValidator.allowed?(email) is false, so the code is never generated and send_login_code_email never runs. The domain check itself works.
  • app/controllers/session_controller.rb (create_login_code): the action deliberately always renders success_json, with the comment “Render the same response as a successful request so bots can’t probe the endpoint.”
  • So the frontend cannot distinguish “code sent” from “refused”, and advances to the code screen in both cases.

Suggestion

Validate the domain at the email step of the code-signup form (the password flow already surfaces this error), or make the code screen copy neutral for the not-sent case.