Ejemplo n.º 1
0
 async def get_user_with_devices_and_trustchain(
         self,
         organization_id: OrganizationID,
         user_id: UserID,
         redacted: bool = False) -> GetUserAndDevicesResult:
     user = self._get_user(organization_id, user_id)
     user_devices = self._get_user_devices(organization_id, user_id)
     user_devices_values = tuple(user_devices.values())
     trustchain = await self._get_trustchain(
         organization_id,
         user.user_certifier,
         user.revoked_user_certifier,
         *[device.device_certifier for device in user_devices_values],
         redacted=redacted,
     )
     return GetUserAndDevicesResult(
         user_certificate=user.redacted_user_certificate
         if redacted else user.user_certificate,
         revoked_user_certificate=user.revoked_user_certificate,
         device_certificates=[
             d.redacted_device_certificate
             if redacted else d.device_certificate
             for d in user_devices.values()
         ],
         trustchain_device_certificates=trustchain.devices,
         trustchain_user_certificates=trustchain.users,
         trustchain_revoked_user_certificates=trustchain.revoked_users,
     )
Ejemplo n.º 2
0
async def query_get_user_with_devices_and_trustchain(
        conn,
        organization_id: OrganizationID,
        user_id: UserID,
        redacted: bool = False) -> GetUserAndDevicesResult:
    user = await _get_user(conn, organization_id, user_id)
    user_devices = await _get_user_devices(conn, organization_id, user_id)
    trustchain = await _get_trustchain(
        conn,
        organization_id,
        user.user_certifier,
        user.revoked_user_certifier,
        *[device.device_certifier for device in user_devices],
        redacted=redacted,
    )
    return GetUserAndDevicesResult(
        user_certificate=user.redacted_user_certificate
        if redacted else user.user_certificate,
        revoked_user_certificate=user.revoked_user_certificate,
        device_certificates=tuple(
            d.redacted_device_certificate if redacted else d.device_certificate
            for d in user_devices),
        trustchain_device_certificates=trustchain.devices,
        trustchain_user_certificates=trustchain.users,
        trustchain_revoked_user_certificates=trustchain.revoked_users,
    )