Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept either username or email in kci user commands #2205

Open
Tracked by #2125
gctucker opened this issue Nov 22, 2023 · 0 comments
Open
Tracked by #2125

Accept either username or email in kci user commands #2205

gctucker opened this issue Nov 22, 2023 · 0 comments

Comments

@gctucker
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant