aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <kimble.mandel@gmail.com>2013-01-10 11:19:07 +0100
committerCédric Bonhomme <kimble.mandel@gmail.com>2013-01-10 11:19:07 +0100
commitcbc4718f58753759a36d8b60e7c6b2f0d37bb4fc (patch)
treebb1a130ac2719ad0a9c4d5b4e15fb7cd515e1062
parentMinor bugfix: the number of favorites articles wasn't passed to the /feed page. (diff)
downloadnewspipe-cbc4718f58753759a36d8b60e7c6b2f0d37bb4fc.tar.gz
newspipe-cbc4718f58753759a36d8b60e7c6b2f0d37bb4fc.tar.bz2
newspipe-cbc4718f58753759a36d8b60e7c6b2f0d37bb4fc.zip
Added change_password function in order to change the password corresponding to username.
-rwxr-xr-xsource/auth.py19
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.
bgstack15