mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-17 09:17:16 +00:00
user registration pages
This commit is contained in:
@@ -31,7 +31,7 @@ def load_users():
|
||||
DataIssue.objects.filter(parser=PARSER_USERS).delete()
|
||||
|
||||
key = settings.LONGTERM_SECRET_KEY # Django generated
|
||||
k = base64.urlsafe_b64encode(key.encode("utf8")[:32]) # make Fernet compatible
|
||||
k = base64.urlsafe_b64encode(key.encode("utf8")[:32]) # make Fernet compatible
|
||||
f = Fernet(k)
|
||||
|
||||
jsonfile = settings.EXPOWEB / ENCRYPTED_DIR / USERS_FILE
|
||||
@@ -43,15 +43,16 @@ def load_users():
|
||||
return None
|
||||
|
||||
with open(jsonfile, 'r', encoding='utf-8') as json_f:
|
||||
message = ""
|
||||
try:
|
||||
registered_users_dict = json.load(json_f)
|
||||
except FileNotFoundError:
|
||||
print("File not found!")
|
||||
message = f"File {jsonfile} not found!"
|
||||
except json.JSONDecodeError:
|
||||
print("Invalid JSON format! - JSONDecodeError")
|
||||
message = f"Invalid JSON format! - JSONDecodeError for {jsonfile}"
|
||||
except Exception as e:
|
||||
print(f"An exception occurred: {str(e)}")
|
||||
message = f"! Troggle USERs. Failed to load {jsonfile} JSON file"
|
||||
message = f"! Troggle USERs. Failed to load {jsonfile} JSON file. Exception <{e}>"
|
||||
if message:
|
||||
print(message)
|
||||
DataIssue.objects.update_or_create(parser=PARSER_USERS, message=message, url=jsonurl)
|
||||
return None
|
||||
@@ -86,11 +87,6 @@ def load_users():
|
||||
return None
|
||||
else:
|
||||
print(f" - user: BAD username for {userdata} ")
|
||||
# if userdata["date"] != "" or userdata["date"] != "None":
|
||||
# message = f"! {str(self.walletname)} Date format not ISO {userdata['date']}. Failed to load from {jsonfile} JSON file"
|
||||
# from troggle.core.models.troggle import DataIssue
|
||||
# DataIssue.objects.update_or_create(parser="wallets", message=message, url=wurl)
|
||||
|
||||
|
||||
ru = []
|
||||
for u in User.objects.all():
|
||||
@@ -106,7 +102,8 @@ def load_users():
|
||||
|
||||
jsondict = { "registered_users": ru }
|
||||
encryptedfile = settings.EXPOWEB / ENCRYPTED_DIR / "encrypt.json"
|
||||
# with open(encryptedfile, 'w', encoding='utf-8') as json_f:
|
||||
# json.dump(jsondict, json_f, indent=1)
|
||||
if settings.DEVSERVER:
|
||||
with open(encryptedfile, 'w', encoding='utf-8') as json_f:
|
||||
json.dump(jsondict, json_f, indent=1)
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user