Skip to content

Commit 5985c0d

Browse files
committed
improved 'piccolo user create' - username defaults to current system user, and added some password validation
1 parent 9086be9 commit 5985c0d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

piccolo/apps/user/commands/create.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
from getpass import getpass
2+
from getpass import getpass, getuser
33

44
from piccolo.apps.user.tables import BaseUser
55

@@ -8,7 +8,10 @@ def create():
88
"""
99
Create a new user.
1010
"""
11-
username = input("Enter username:\n")
11+
default_username = getuser()
12+
username = input(f"Enter username ({default_username}):\n")
13+
username = default_username if not username else username
14+
1215
email = input("Enter email:\n")
1316

1417
password = getpass("Enter password:\n")
@@ -18,6 +21,10 @@ def create():
1821
print("Passwords don't match!")
1922
sys.exit(1)
2023

24+
if len(password) < 4:
25+
print("The password is too short")
26+
sys.exit(1)
27+
2128
while True:
2229
admin = input("Admin user? Enter y or n:\n")
2330
if admin in ("y", "n"):

0 commit comments

Comments
 (0)