Add 3-attempt limit to `get_user_token`
The previous implementation of `get_user_token` could recurse indefinitely
if the user repeatedly provided an invalid token. This commit introduces a
`max_attempts` limit (set to 3) to prevent this.
The function now fails with an error if:
1. The 3-attempt limit is reached.
2. A `cli_token` is provided but is found to be invalid.
To implement this, the function was refactored as follows:
- An inner recursive `loop` function is now used to track the
`attempts_left` counter.
- The user-prompting logic is extracted to a new helper
function, `prompt_for_token`.
- The file-writing logic is extracted to a new helper
function, `save_token_file`.
1aad2c
-
-
Jan 09 21:47 +00:00