diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2025-01-23 23:38:06 +0000 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2025-01-23 23:38:06 +0000 |
commit | a5d0ad3e4f92147ea07a13e236389914ab4a57b7 (patch) | |
tree | 6b6cb4e23aecdd90da9c2f09b8ab730dab6de380 /parsers/users.py | |
parent | f842dab12a8bd807a0bb61a6eb35600b789564b0 (diff) | |
download | troggle-a5d0ad3e4f92147ea07a13e236389914ab4a57b7.tar.gz troggle-a5d0ad3e4f92147ea07a13e236389914ab4a57b7.tar.bz2 troggle-a5d0ad3e4f92147ea07a13e236389914ab4a57b7.zip |
New User registration form
Diffstat (limited to 'parsers/users.py')
-rw-r--r-- | parsers/users.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/parsers/users.py b/parsers/users.py index fe11bdf..cf721ba 100644 --- a/parsers/users.py +++ b/parsers/users.py @@ -25,20 +25,25 @@ todo = """ USERS_FILE = "users.json" ENCRYPTED_DIR = "encrypted" -def register_user(u, email, password=None, pwhash=None): +def register_user(u, email, password=None, pwhash=None, fullname=None): + """Create User and we may not have a Person to tie it to if it is a future caver. + Do not use the lastname field, put the whole free text identification into firstname + as this saves hassle and works with Wookey too + """ try: if existing_user := User.objects.filter(username=u): # WALRUS print(f" - deleting existing user '{existing_user[0]}' before importing") existing_user[0].delete() - user = User.objects.create_user(u, email) + user = User.objects.create_user(u, email, first_name=fullname) if pwhash: user.password = pwhash elif password: user.set_password(password) # function creates hash and stores hash print(f" # hashing provided clear-text password {password} to make pwhash for user {u}") else: - user.set_password('secret') # function creates hash and stores hash - print(f" # hashing 'secret' password to make pwhash for user {u}") + # user.set_password(None) # use Django special setting for invalid password, but then FAILS to send password reset email + user.set_password("secret") # Why is the Django logic broken. Hmph. + print(f" # setting INVALID password for user {u}, must be reset by password_reset") user.is_staff = False user.is_superuser = False user.save() |