grim/containers/reviewboard

Update to reviewboard 5.0

21 months ago, Gary Kramlich
0cc520b67a7c
Update to reviewboard 5.0
diff --git a/reviewboard/accounts/sso/backends/saml/views.py b/reviewboard/accounts/sso/backends/saml/views.py
index 5b6397a1b..f792d8dca 100644
--- a/reviewboard/accounts/sso/backends/saml/views.py
+++ b/reviewboard/accounts/sso/backends/saml/views.py
@@ -328,6 +328,26 @@ class SAMLACSView(SAMLViewMixin, BaseSSOView):
if value and isinstance(value, list):
return value[0]
+ if key in ('User.FirstName', 'User.LastName'):
+ try:
+ fullname = self._get_user_attr_value(auth, 'User.FullName')
+ except KeyError:
+ # Just raise the KeyError with the original key, as
+ # KeyError.__str__ will quote the entire parameter. So if we
+ # tried to append 'User.FullName` we would output something like
+ # "'User.FullName or User.LastName'" instead of
+ # "'User.FullName' or 'User.LastName'".
+ raise KeyError(key)
+
+ # we don't have a good way to split the username to a first
+ # name/last name, so we split on the first space and then treat the
+ # two parts as the first and last names.
+ name_parts = fullname.split(' ', 1)
+ if key == 'User.FirstName':
+ return name_parts[0]
+ else:
+ return len(name_parts) > 1 and name_parts[1] or ''
+
raise KeyError(key)