made a lot of stuff
This commit is contained in:
@@ -62,7 +62,6 @@ while True:
|
||||
|
||||
# FAILSAFE 1: Ignore folders or non-txt files (like .DS_Store or .tmp)
|
||||
if not file_path.is_file() or file_path.suffix != ".txt":
|
||||
print(f"Skipping non-txt file: {file_path.name}")
|
||||
continue
|
||||
|
||||
try:
|
||||
@@ -107,19 +106,33 @@ while True:
|
||||
if verify_password(password, data):
|
||||
file_path.rename(status_path / f"success_{file_path.name}")
|
||||
# move and rename to success_filename.txt in status
|
||||
print(f"{user} login success.")
|
||||
else:
|
||||
file_path.rename(status_path / f"fail_{file_path.name}")
|
||||
print(f"{user} hash did not match.")
|
||||
else:
|
||||
file_path.rename(status_path / f"fail_{file_path.name}")
|
||||
print(f"{user} does not exist.")
|
||||
|
||||
elif command == "CREATEUSER":
|
||||
# TODO
|
||||
|
||||
#2. Hash password and store in hash.txt
|
||||
#3. Init basic files
|
||||
#4. Make success request file
|
||||
#5. Fail file as try/except
|
||||
pass
|
||||
new_user_path = user_path / user
|
||||
|
||||
if new_user_path.exists():
|
||||
file_path.rename(status_path / f"fail_{file_path.name}")
|
||||
print(f"{user} already exists!")
|
||||
else:
|
||||
try:
|
||||
new_user_path.mkdir(parents=True)
|
||||
with open(new_user_path / "pass.txt", "w") as password:
|
||||
password.write(hash_password(data))
|
||||
with open(new_user_path / "info.txt", "w") as info:
|
||||
info.write(f"{user}\n\n\nA new user")
|
||||
print(f"{user} created!")
|
||||
file_path.rename(status_path / f"success_{file_path.name}")
|
||||
except Exception as e:
|
||||
print(f"Something went wrong while trying to create {user}: {e}")
|
||||
file_path.rename(status_path / f"fail_{file_path.name}")
|
||||
continue
|
||||
|
||||
elif file_path.is_file():
|
||||
file_path.unlink()
|
||||
@@ -130,4 +143,4 @@ while True:
|
||||
continue
|
||||
|
||||
# 5. Heartbeat
|
||||
time.sleep(0.1)
|
||||
time.sleep(0.5)
|
||||
Reference in New Issue
Block a user