1
0
Fork 0

Login.py: use password instead of psd because psd may cause confusion.

WangXuan-Highlight-Pronounce
Lan Hui 2022-01-27 12:28:41 +08:00
parent 0c923f7db2
commit 718b98ef02
1 changed files with 5 additions and 5 deletions

View File

@ -34,18 +34,18 @@ def check_username_availability(username):
return result == [] return result == []
def change_password(username, old_psd, new_psd): def change_password(username, old_password, new_password):
''' '''
修改密码 修改密码
:param username: 用户名 :param username: 用户名
:param old_psd: 旧的密码 :param old_password: 旧的密码
:param new_psd: 新密码 :param new_password: 新密码
:return: 修改成功:True 否则:False :return: 修改成功:True 否则:False
''' '''
if not verify_user(username, old_psd): # 旧密码错误 if not verify_user(username, old_password): # 旧密码错误
return False return False
# 将用户名和密码一起加密,以免暴露不同用户的相同密码 # 将用户名和密码一起加密,以免暴露不同用户的相同密码
password = md5(username + new_psd) password = md5(username + new_password)
rq = InsertQuery(path_prefix + 'static/wordfreqapp.db') rq = InsertQuery(path_prefix + 'static/wordfreqapp.db')
rq.instructions("UPDATE user SET password = '%s' WHERE name = '%s'" % (password, username)) rq.instructions("UPDATE user SET password = '%s' WHERE name = '%s'" % (password, username))
rq.do() rq.do()