diff options
author | Cédric Bonhomme <kimble.mandel@gmail.com> | 2013-01-10 18:23:51 +0100 |
---|---|---|
committer | Cédric Bonhomme <kimble.mandel@gmail.com> | 2013-01-10 18:23:51 +0100 |
commit | c68b08ba39e7f5ef83eccb57168cf28cb64dac71 (patch) | |
tree | 180bdc6169e72468d9cb23cce6e51ae2f107b1cb /source/auth.py | |
parent | error() is called when the password can't be changed. (diff) | |
download | newspipe-c68b08ba39e7f5ef83eccb57168cf28cb64dac71.tar.gz newspipe-c68b08ba39e7f5ef83eccb57168cf28cb64dac71.tar.bz2 newspipe-c68b08ba39e7f5ef83eccb57168cf28cb64dac71.zip |
Added possibility to change the username.
Diffstat (limited to 'source/auth.py')
-rwxr-xr-x | source/auth.py | 19 |
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. |