From a882396f09f94bbb03d052f8080a58affb012d09 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 9 Apr 2021 22:20:30 +0200 Subject: [PATCH] check the propertary of the devices --- ereuse_devicehub/resources/action/schemas.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ereuse_devicehub/resources/action/schemas.py b/ereuse_devicehub/resources/action/schemas.py index 658f1654..725d859c 100644 --- a/ereuse_devicehub/resources/action/schemas.py +++ b/ereuse_devicehub/resources/action/schemas.py @@ -514,6 +514,13 @@ class Offer(ActionWithMultipleDevices): if data['user_from_id']: user_from = User.query.filter_by(email=data['user_from_id']).one() + + # are you property of this devices? + txt = "Some of this devices don't are of this from user" + for x in data['devices']: + if not x.owner == user_from: + raise ValidationError(txt) + data['user_from_id'] = user_from.id data['user_from'] = user_from else: