Skip to content

Commit

Permalink
Fix API token not being returned on user create
Browse files Browse the repository at this point in the history
This is a side effect of CVE Services now returning time information for
all requests:

CVEProject/cve-services#451

Resolves #8
  • Loading branch information
mprpic committed Oct 25, 2021
1 parent 4471fff commit a49452d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cvelib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ def print_user(user):
if name:
click.echo(f"{name} — ", nl=False)
click.echo(user["username"])

# If this is a newly created user, print out the API token.
if "secret" in user:
click.echo(f"├─ API token:\t{user['secret']}")

click.echo(f"├─ Active:\t{bool_to_text(user['active'])}")
click.echo(f"├─ Roles:\t{', '.join(user['authority']['active_roles']) or 'None'}")

# Time values are not returned when creating users; secrets (API tokens) are however.
if "time" in user:
click.echo(f"├─ Created:\t{human_ts(user['time']['created'])}")
click.echo(f"└─ Modified:\t{human_ts(user['time']['modified'])}")
elif "secret" in user:
click.echo(f"└─ API token:\t{user['secret']}")
click.echo(f"├─ Created:\t{human_ts(user['time']['created'])}")
click.echo(f"└─ Modified:\t{human_ts(user['time']['modified'])}")


def get_full_name(user_data):
Expand Down

0 comments on commit a49452d

Please sign in to comment.