Members who have added a passkey but have no authenticator app or security key can’t log in with username and password any more. Every attempt fails with The selected two-factor method is not enabled for your account. Logging in with the passkey, or with an email code, still works.
Steps to reproduce
- Leave
enable_passkeysandallow_passkeys_for_2faat their defaults (both on). - As a user with no 2FA, add a passkey in Preferences > Security.
- Log out, then log in with username and password.
Expected: the user is logged in. They have no second factor, so none should be asked for.
Actual: the login is refused with not_enabled_second_factor_method, every time.
Cause
The login form always posts a second factor method, TOTP by default (frontend/discourse/app/controllers/login.js, secondFactorMethod = SECOND_FACTOR_METHODS.TOTP, sent as second_factor_method).
SecondFactorManager#authenticate_second_factor only returns early when
!requires_second_factor_for_login? &&
(!passkeys_available_as_second_factor? || params[:second_factor_method].blank?)
A passkey makes passkeys_available_as_second_factor? true, and the form makes the method non-blank. So the check falls through to valid_second_factor_method_for_user?(TOTP), which fails because the user has no TOTP.
This came in with #39674 (passkeys as 2FA on /session/2fa) and is still the same on main today.
Possible fix
Only fall through when the request really asks for a passkey:
if !requires_second_factor_for_login? &&
(
!passkeys_available_as_second_factor? ||
params[:second_factor_method].to_i != UserSecondFactor.methods[:passkey]
)
return ok_result
end
Or have the login form leave second_factor_method empty until the server asks for a second factor.
Workaround for anyone hitting this: turn off allow_passkeys_for_2fa. Password login works again straight away, and “Log in with a passkey” keeps working. You lose passkeys as a 2FA step on /session/2fa.