chat_core.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:best-ever-chat 作者: lazymeadow 项目源码 文件源码
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.')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号