Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Authenticate ¶
func Authenticate( client client.HTTPClient, module *module.Module, password string, silent bool, ) ([]*http.Cookie, error)
Authenticate performs authentication against the partners.1c-bitrix.ru service using the provided module and password.
Parameters:
- module (*module.Module): The module object. If nil, the function returns errors.ErrNilModule.
- password (string): The password used for authentication. If empty, the function returns errors.ErrEmptyPassword.
- silent (bool): Skip spinner.
Returns:
- []*http.Cookie: A slice of cookies obtained from the authentication response, typically used for session management.
- Error: Any error encountered during parameter validation or the authentication process.
Description: First validates that both the module and password are provided and non-empty. It creates an HTTP client with an associated cookie jar and wraps it using a request.client. Using a spinner for progress feedback, it calls httpClient.Authenticate with the module’s account and password. If authentication succeeds, the function returns the configured client and cookies; otherwise, it returns the encountered error.
func InputPassword ¶
InputPassword manages the process of obtaining and validating the password needed for authentication. It first checks if the password was provided as a flag, then checks environment variables, and if neither are found, it prompts the user to enter a password interactively.
Parameters: - cmd (*cobra.Command): The Cobra command that invoked the function. - module (*internal.Module): The module for which the password is being provided (may use environment variable).
Returns: - string: The validated password. - error: An error if the password is invalid or the prompt fails.
Types ¶
This section is empty.