diff options
author | meltland <[email protected]> | 2025-03-28 14:11:46 -0400 |
---|---|---|
committer | meltland <[email protected]> | 2025-03-28 14:11:46 -0400 |
commit | cd1945e802cc589e7543f4e88096e8dfcab3721b (patch) | |
tree | 61033d3ea9760b3fcd7559c2abcd4cced31ba34e /main.py | |
parent | ebc7ef7f70e1eda6cab3dca24cf7e2c3cb4d3246 (diff) |
account deletion
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/main.py b/main.py index 15be7a4..49d6b49 100644 --- a/main.py +++ b/main.py @@ -16,7 +16,7 @@ from urllib.parse import urlparse with open("config.json", "r") as f: config_file = json.load(f) -version = "Helium-1.0.0a" +version = "Helium-1.0.1a" attachment_whitelist = config_file["whitelisted_urls"] contributors = [] @@ -64,6 +64,31 @@ clients = [] invite_codes = [] locked = False +if db.acc.get("deleted") == "notExists": + db.acc.add({ + "_id": "00000000-0000-0000-0000-000000000000", + "username": "deleted", + "display_name": "deleted", + "created": 0, + "avatar": None, + "bot": False, + "banned_until": 32503698000, + "permissions": [], + "profile": { + "bio": "", + "lastfm": "", + "banner": None, + "links": {} + }, + "secure": { + "password": "", + "token": "", + "ban_reason": "", + "invite_code": "", + "support_code": "" + } + }) + class util: def error(code, listener, data=None): if code in error_contexts: @@ -212,7 +237,7 @@ async def handler(websocket): "_id": str(uuid.uuid4()), "username": r["username"], "display_name": r["username"], - "created": round(time.time()), + "created": time.time(), "avatar": None, "bot": False, "banned_until": 0, @@ -571,6 +596,27 @@ async def handler(websocket): })) await websocket.send(json.dumps({"error": False, "listener": listener})) continue + elif r["command"] == "delete_account": + fc = util.field_check({"password": range(8,256)}, r) + if fc != True: + await websocket.send(util.error(fc, listener)) + continue + if str(websocket.id) not in client_data: + await websocket.send(util.error("unauthorized", listener)) + continue + username = client_data[str(websocket.id)]["username"] + vf = db.acc.verify_pswd(username, r["password"]) + if type(vf) == dict: + ac = db.acc.remove(username) + if ac != True: + await websocket.send(util.error(ac, listener)) + continue + await websocket.send(json.dumps({"error": False, "listener": listener})) + await websocket.close() + continue + else: + await websocket.send(util.error("unauthorized", listener)) + continue elif r["command"] == "ping": pass elif r["command"] in deprecated: |