From 70a9897beb3fdbab8dd6e7067e5e5ab402861380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 28 Dec 2015 16:14:59 +0100 Subject: [PATCH] api: protect against removed roles (#9447) --- wcs/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wcs/api.py b/wcs/api.py index 315fb3b..f168375 100644 --- a/wcs/api.py +++ b/wcs/api.py @@ -420,8 +420,8 @@ class ApiUserDirectory(Directory): user_info = user.get_substitution_variables(prefix='') del user_info['user'] user_info['id'] = user.id - user_info['user_roles'] = [ - Role.get(x).get_json_export_dict() for x in user.roles or []] + user_roles = [Role.get(x, ignore_errors=True) for x in user.roles or []] + user_info['user_roles'] = [x.get_json_export_dict() for x in user_roles if x] return json.dumps(user_info) def get_user_forms(self, user): -- 2.6.4