From 3071d76ae1708db2b0e07c5ac666f89e8f22226f Mon Sep 17 00:00:00 2001 From: Brian Wiborg Date: Sat, 27 Sep 2025 16:50:15 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20Add=20password=20verification?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ohmyapi/cli.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/ohmyapi/cli.py b/src/ohmyapi/cli.py index 6479fe8..38d8fcc 100644 --- a/src/ohmyapi/cli.py +++ b/src/ohmyapi/cli.py @@ -16,13 +16,13 @@ Find your loaded project singleton via identifier: `p` @app.command() def startproject(name: str): - """Create a new OhMyAPI project in the given directory""" + """Create a new OhMyAPI project in the given directory.""" scaffolding.startproject(name) @app.command() def startapp(app_name: str, root: str = "."): - """Create a new app with the given name in your OhMyAPI project""" + """Create a new app with the given name in your OhMyAPI project.""" scaffolding.startapp(app_name, root) @@ -93,6 +93,10 @@ def migrate(app: str = "*", root: str = "."): @app.command() def createsuperuser(root: str = "."): + """Create a superuser in the DB. + + This requires the presence of `ohmyapi_auth` in your INSTALLED_APPS to work. + """ project_path = Path(root).resolve() project = runtime.Project(project_path) if not project.is_app_installed("ohmyapi_auth"): @@ -103,9 +107,14 @@ def createsuperuser(root: str = "."): import ohmyapi_auth email = input("E-Mail: ") username = input("Username: ") - password = getpass("Password: ") + password1, password2 = "foo", "bar" + while password1 != password2: + password1 = getpass("Password: ") + password2 = getpass("Repeat Password: ") + if password1 != password2: + print("Passwords didn't match!") user = ohmyapi_auth.models.User(email=email, username=username, is_staff=True, is_admin=True) - user.set_password(password) + user.set_password(password1) asyncio.run(project.init_orm()) asyncio.run(user.save()) asyncio.run(project.close_orm())