Prompt for TFA code in CLI on PSTATUS_TFA_REQUIRED. - #209
Open
julienisapunk wants to merge 3 commits into
Open
Conversation
The library already exposes psync_tfa_send_nofification / psync_tfa_send_sms / psync_tfa_set_code, but the console client never wired them up, so a login on a TFA-protected (or new-device-verified) account looped forever on LOGIN_REQUIRED. Handle PSTATUS_TFA_REQUIRED by triggering a code via notification (falling back to SMS), reading it from stdin, and submitting it with trust=1; re-prompt on PSTATUS_BAD_TFA_CODE. A 'r:' prefix routes to psync_tfa_set_code with is_recovery=1 for recovery codes.
get_connected_socket() only cleared a pending two factor code for results 2000/2012/2064/2074/2092. Anything else fell through to the bare psync_milisleep(PSYNC_SLEEP_BEFORE_RECONNECT) with psync_my_2fa_code still set, so the next iteration resent the same code. A malformed code gets 1022 "Please provide 'code'" rather than 2012, so entering one wedged the login in a silent five second retry loop: status stayed CONNECTING, no PSTATUS_AUTH_BADCODE was ever raised, the CLI never re-prompted, and psync_fs_start() never ran -- leaving an empty mountpoint and nothing on screen to explain why. Discard the code and raise PSTATUS_AUTH_BADCODE for any unhandled result while one is pending, so the existing PSTATUS_BAD_TFA_CODE handler asks again. Also normalize what is typed at the prompt before it reaches the API, since 1022 is indistinguishable from a genuinely missing parameter: trim whitespace, drop spaces and dashes inside the code, read 'r:' or 'recovery:' (any case) as the recovery marker, reject a non-recovery code holding non-digits or one longer than psync_my_2fa_code's 31 usable bytes, and re-prompt locally instead of spending a round trip on input that cannot work. Exit on stdin EOF instead of submitting an empty code. The marker has to carry its colon. A bare leading 'r' is far more likely a mistyped device code than a real recovery code, since codes sent to a device are six digits while tfa_loginwithrecoverycode wants something longer, so treating it as the marker would only trade a local rejection for a round trip that comes back 2012. 'r341820' now fails the digits check and the user is pointed at the prefix instead. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Building the vendored mbedtls the documented way ("cmake ." then "make" in
pCloudCC/lib/mbedtls) writes a Makefile into every configured subdirectory.
mbedtls' own .gitignore lists CMakeCache.txt, CMakeFiles and
cmake_install.cmake but not these, so they showed up as untracked and were
easy to stage by accident. Nothing named Makefile is tracked anywhere under
that tree -- only CMakeLists.txt files -- so one anchored pattern covers the
top level, library/, and anything configured later.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
The library already exposes psync_tfa_send_nofification / psync_tfa_send_sms / psync_tfa_set_code, but the console client never wired them up, so a login on a TFA-protected (or new-device-verified) account looped forever on LOGIN_REQUIRED. Handle PSTATUS_TFA_REQUIRED by triggering a code via notification (falling back to SMS), reading it from stdin, and submitting it with trust=1; re-prompt on PSTATUS_BAD_TFA_CODE. A 'r:' prefix routes to psync_tfa_set_code with is_recovery=1 for recovery codes.