From 40a31aba9e12ae6637cdcc93e2e3a8b8ab2c8756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 10 Mar 2015 14:08:33 +0100 Subject: [PATCH] save provisioned users (#6667) --- mellon/adapters.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mellon/adapters.py b/mellon/adapters.py index fecd694..c11b679 100644 --- a/mellon/adapters.py +++ b/mellon/adapters.py @@ -68,6 +68,7 @@ class DefaultAdapter(object): def provision_attribute(self, user, idp, saml_attributes): realm = utils.get_setting(idp, 'REALM') attribute_mapping = utils.get_setting(idp, 'ATTRIBUTE_MAPPING') + attribute_set = False for field, tpl in attribute_mapping.iteritems(): try: value = unicode(tpl).format(realm=realm, attributes=saml_attributes, idp=idp) @@ -76,7 +77,10 @@ class DefaultAdapter(object): except (AttributeError, KeyError, IndexError, ValueError), e: log.warning('invalid reference in attribute mapping template %r: %s', tpl, e) else: + attribute_set = True setattr(user, field, value) + if attribute_set: + user.save() def provision_superuser(self, user, idp, saml_attributes): superuser_mapping = utils.get_setting(idp, 'SUPERUSER_MAPPING')