user.py 文件源码

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

项目:blog-server 作者: chehThss 项目源码 文件源码
def startup(self):
        password = 'root'
        password = password.encode('utf-8')
        hashed = bcrypt.hashpw(password, bcrypt.gensalt())
        root = await self.db.find_one({'user': ROLE_ROOT})
        if root is None:
            root = await self.db.insert_one({
                'user': ROLE_ROOT,
                'password': hashed,
                'role': 'administrator',
            })
            self.__root_id = str(root.inserted_id)
        else:
            self.__root_id = str(root['_id'])
        self.event.emit('user-add', {
            'id': self.__root_id,
            'user': 'root'
        })
        await self.db.create_index('user')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号