diff options
Diffstat (limited to 'source/auth.py')
-rwxr-xr-x | source/auth.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/source/auth.py b/source/auth.py index dbe6a1cc..cf451e7f 100755 --- a/source/auth.py +++ b/source/auth.py @@ -50,7 +50,24 @@ class excel_french(csv.Dialect): csv.register_dialect('excel_french', excel_french) - +def change_password(username, new_password, 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([user[0], new_password]) + result = True + else: + cw.writerow(user) + return result def check_credentials(username, password): """Verifies credentials for username and password. |