Coverage for compiler_admin / commands / user / reset.py: 100%
23 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-28 05:48 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-28 05:48 +0000
1import click
3from compiler_admin import Result
4from compiler_admin.commands.user.signout import signout
5from compiler_admin.services.google import GoogleAccount, GoogleUsers
8@click.command()
9@click.option("-f", "--force", is_flag=True, help="Don't ask for confirmation.")
10@click.option("-n", "--notify", help="An email address to send the new password notification.")
11@click.argument("username")
12@click.pass_context
13def reset(ctx: click.Context, username: str, force: bool = False, notify: str = "", **kwargs):
14 """Reset a user's password."""
15 account = GoogleAccount(username)
16 google = GoogleUsers()
18 if not account.exists():
19 click.echo(f"User does not exist: {account}")
20 raise SystemExit(Result.FAILURE)
22 if not force:
23 cont = input(f"Reset password for {account}? (Y/n): ")
24 if not cont.lower().startswith("y"):
25 click.echo("Aborting password reset.")
26 raise SystemExit(Result.SUCCESS)
28 click.echo(f"User exists, resetting password: {account}")
30 google.reset_password(account=account, notify=notify)
32 # call the signout command
33 ctx.forward(signout)