Feature: Login process in Initialization of lean folder #486
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.
Description
This PR introduces enhancements to the Lean CLI authentication process. Specifically, it modifies the
lean init
command to prompt users for authentication if their credentials are not available or invalid. Instead of throwing an exception when no user is found, the system now initiates the login process and stores the credentials in the Lean configuration file.Key changes include:
get_lean_config_credentials
function is used to fetch existing credentials from the Lean configuration.get_credentials
function is called to prompt the user for their user ID and API token.validate_credentials
function ensures that the provided credentials are valid and correctly authenticated.Related Issue
Closes #483
Motivation and Context
Previously, if the
lean init
command was run without valid credentials, the system would raise an exception with the message Error: User not found: None, which was not user-friendly and could be confusing.This update improves the user experience by:
By integrating these changes, we aim to streamline the setup process and reduce friction for users getting started with the Lean CLI.
How Has This Been Tested?
Manual Testing
lean login
command to ensure that the login process is functioning as expected and has not introduced any issues.lean init
command to verify that it correctly prompts for login credentials when they are missing or invalid, and that it successfully initiates the login process.