fixing same tag 2 users get with a validate user

This commit is contained in:
Cayo Puigdefabregas 2021-02-26 18:59:32 +01:00
parent 8d6e50ece9
commit adcb330b87

View file

@ -66,11 +66,19 @@ class TagDeviceView(View):
def one(self, id):
"""Gets the device from the tag."""
if request.authorization:
return self.one_authorization(id)
tag = Tag.from_an_id(id).one() # type: Tag
if not tag.device:
raise TagNotLinked(tag.id)
if not request.authorization:
return redirect(location=url_for_resource(Device, tag.device.id))
return redirect(location=url_for_resource(Device, tag.device.id))
@auth.Auth.requires_auth
def one_authorization(self, id):
tag = Tag.from_an_id(id).filter_by(owner=g.user).one() # type: Tag
if not tag.device:
raise TagNotLinked(tag.id)
return app.resources[Device.t].schema.jsonify(tag.device)
# noinspection PyMethodOverriding