Skip to content

Accept either username or email in kci user commands #2205

@gctucker

Description

@gctucker

Some kci user commands such as kci user password reset and kci user verify currently take a username argument to find the user in order to be consistent with other commands. However, these operations rely on an email address and could also be done just by providing an email address instead of the username. Generally speaking, as usernames can't contain symbols such as @ (to be confirmed...) then users can be found using either their username or email in exactly the same way.

So all the kci user command that have a username argument could instead have a login argument which could be either a username or an email address. Then we could have a helper method in kernelci.cli to get a user from the API:

def find_user(api, login):
    users = (
        api.user.find({"username": login}) or
        api.user.find({"email": login})
    )
    if not users:
        raise click.ClickException(f"User not found: {login}")
    return users[0]

This might even be made part of the APIHelper class, without the Click exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions