Browse Source

Added functionality to add user credentials when user does not exist

master
Leo Maroni 1 year ago
parent
commit
0195f19175
Signed by: em0lar GPG Key ID: B1ADA545CD2CBACD
  1. 9
      wifi_radius_manager.py

9
wifi_radius_manager.py

@ -166,11 +166,16 @@ def capitalize_first_letter(s):
def set_password(username: str, password: str):
found = False
for line in fileinput.input(os.environ.get("USER_FILE_PATH"), inplace=True):
if line.startswith(username):
if not found and line.startswith(username):
print(username + ' Cleartext-Password := "' + password + '"', end='\n')
elif line != "\n":
found = True
elif line != "\n" and not line.startswith(username):
print(line)
user_file = open(os.environ.get("USER_FILE_PATH"), "a")
if not found:
user_file.write(username + ' Cleartext-Password := "' + password + '"\n')
def get_password(username: str):

Loading…
Cancel
Save