Пример #1
0
def do_register(
    username: str,
    email: str,
    password: str,
    password_confirmation: str,
    no_subscribe: bool,
) -> None:
    """
    Register a new Registry account and save auth token.

    :param username: str username.
    :param email: str email.
    :param password: str password.
    :param password_confirmation: str password confirmation.
    :param no_subscribe: bool flag for developers subscription skip on register.

    :return: None
    """
    username = validate_author_name(username)
    token = register_new_account(username, email, password,
                                 password_confirmation)
    update_cli_config({AUTH_TOKEN_KEY: token})
    if not no_subscribe and click.confirm(
            "Do you want to subscribe for developer news?"):
        click.echo("Please visit `https://aea-registry.fetch.ai/mailing-list` "
                   "to subscribe for developer news")
    click.echo("Successfully registered and logged in: {}".format(username))
Пример #2
0
def do_init(author: str, reset: bool, registry: bool,
            no_subscribe: bool) -> None:
    """
    Initialize your AEA configurations.

    :param author: str author username.
    :param reset: True, if resetting the author name
    :param registry: True, if registry is used
    :param no_subscribe: bool flag for developers subscription skip on register.

    :return: None.
    """
    config = get_or_create_cli_config()
    if reset or config.get(AUTHOR_KEY, None) is None:
        author = validate_author_name(author)
        if registry:
            _registry_init(username=author, no_subscribe=no_subscribe)

        update_cli_config({AUTHOR_KEY: author})
        config = get_or_create_cli_config()
        config.pop(AUTH_TOKEN_KEY, None)  # for security reasons
        success_msg = "AEA configurations successfully initialized: {}".format(
            config)
    else:
        config.pop(AUTH_TOKEN_KEY, None)  # for security reasons
        success_msg = "AEA configurations already initialized: {}. To reset use '--reset'.".format(
            config)
    click.echo(AEA_LOGO + "v" + __version__ + "\n")
    click.echo(success_msg)
Пример #3
0
def do_logout() -> None:
    """
    Logout from Registry account.

    :return: None.
    """
    registry_logout()
    update_cli_config({AUTH_TOKEN_KEY: None})
Пример #4
0
def do_login(username: str, password: str):
    """
    Login to Registry account and save auth token in config.

    :param username: str username.
    :param password: str password.

    :return: None
    """
    click.echo("Signing in as {}...".format(username))
    token = registry_login(username, password)
    update_cli_config({AUTH_TOKEN_KEY: token})
    click.echo("Successfully signed in: {}.".format(username))
Пример #5
0
def do_register(
    username: str, email: str, password: str, password_confirmation: str
) -> None:
    """
    Register a new Registry account and save auth token.

    :param username: str username.
    :param email: str email.
    :param password: str password.
    :param password_confirmation: str password confirmation.

    :return: None
    """
    username = validate_author_name(username)
    token = register_new_account(username, email, password, password_confirmation)
    update_cli_config({AUTH_TOKEN_KEY: token})
    click.echo("Successfully registered and logged in: {}".format(username))
Пример #6
0
 def testupdate_cli_config_positive(self, dump_mock, icf_mock):
     """Test for update_cli_config method positive result."""
     update_cli_config({"some": "config"})
     icf_mock.assert_called_once()
     dump_mock.assert_called_once()
Пример #7
0
def logout():
    """Logout from Registry account."""
    click.echo("Logging out...")
    registry_logout()
    update_cli_config({AUTH_TOKEN_KEY: None})
    click.echo("Successfully logged out.")