def change_user_password(self, user, password_list):
"""
Update a user's password to the given value. Requires that the value be sent with a confirmation entry (two
identical values)
:param user: user with the password change
:param password_list: list containing password and confirmation
:return: for exiting if necessary information is not available
"""
if user != self.username or not password_list or len(password_list) != 2 or password_list[0] != password_list[
1]:
return
updating_participants = get_matching_participants(self.participants, self.current_user['id'])
hashed_password = yield executor.submit(
bcrypt.hashpw, tornado.escape.utf8(password_list[0]),
bcrypt.gensalt())
if self.current_user.password != hashed_password:
self.http_server.db.execute("UPDATE parasite SET password = %s WHERE id = %s", hashed_password,
self.current_user['id'])
self.broadcast_from_server(updating_participants, 'PASSWORD CHANGED! I hope that\'s what you wanted.')
评论列表
文章目录