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')
评论列表
文章目录