aboutsummaryrefslogtreecommitdiff
path: root/source/auth.py
diff options
context:
space:
mode:
Diffstat (limited to 'source/auth.py')
-rwxr-xr-xsource/auth.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/source/auth.py b/source/auth.py
index 33fafcda..9ca1c46f 100755
--- a/source/auth.py
+++ b/source/auth.py
@@ -49,6 +49,25 @@ class excel_french(csv.Dialect):
csv.register_dialect('excel_french', excel_french)
+def change_username(username, new_username, password_file='./var/password'):
+ """
+ Change the password corresponding to username.
+ """
+ users_list = []
+ result = False
+ with open(password_file, 'r') as csv_readfile_read:
+ cr = csv.reader(csv_readfile_read, 'excel_french')
+ users_list = [elem for elem in cr]
+ with open(password_file, 'w') as csv_file_write:
+ cw = csv.writer(csv_file_write, 'excel_french')
+ for user in users_list:
+ if user[0] == username:
+ cw.writerow([new_username, user[1]])
+ result = True
+ else:
+ cw.writerow(user)
+ return result
+
def change_password(username, new_password, password_file='./var/password'):
"""
Change the password corresponding to username.
bgstack15