We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent be5711f commit 341e305Copy full SHA for 341e305
care/users/api/serializers/user.py
@@ -432,3 +432,26 @@ class Meta:
432
"home_facility",
433
"video_connect_link",
434
)
435
+
436
+ def to_representation(self, instance):
437
+ representation = super().to_representation(instance)
438
+ user = self.context["request"].user
439
440
+ if user.user_type < User.TYPE_VALUE_MAP["Reserved"]:
441
+ whitelisted_fields = (
442
+ "id",
443
+ "first_name",
444
+ "last_name",
445
+ "username",
446
+ "local_body_object",
447
+ "district_object",
448
+ "state_object",
449
+ "user_type",
450
+ "created_by",
451
+ )
452
453
+ for key in list(representation.keys()):
454
+ if key not in whitelisted_fields:
455
+ representation.pop(key)
456
457
+ return representation
0 commit comments