From: deyk Date: Mon, 16 Apr 2012 18:46:59 +0000 (-0700) Subject: Changed from custom attribute callback to signal for collecting custom attributes. X-Git-Tag: 22.4~26 X-Git-Url: https://git.mdrn.pl/django-cas-provider.git/commitdiff_plain/7de1822447fb622522fdce31d0f0e02fa3cdcbd5 Changed from custom attribute callback to signal for collecting custom attributes. --- diff --git a/cas_provider/signals.py b/cas_provider/signals.py index 5a16f9f..648a0de 100644 --- a/cas_provider/signals.py +++ b/cas_provider/signals.py @@ -7,3 +7,5 @@ from django import dispatch on_cas_collect_histories = dispatch.Signal(providing_args=["for_email"]) on_cas_login = dispatch.Signal(providing_args=["request"]) + +cas_collect_custom_attributes = dispatch.Signal(providing_args=['user']) diff --git a/cas_provider/views.py b/cas_provider/views.py index 3f2607f..e896fba 100644 --- a/cas_provider/views.py +++ b/cas_provider/views.py @@ -336,12 +336,14 @@ def auth_success_response(user, pgt, proxies): username = etree.SubElement(auth_success, CAS + 'user') username.text = user.username - if settings.CAS_CUSTOM_ATTRIBUTES_CALLBACK: - callback = get_callable(settings.CAS_CUSTOM_ATTRIBUTES_CALLBACK) - attrs = callback(user) - if len(attrs) > 0: - formatter = get_callable(settings.CAS_CUSTOM_ATTRIBUTES_FORMATER) - formatter(auth_success, attrs) + attrs = {} + for receiver, response in signals.cas_collect_custom_attributes.send(user): + if response: + attrs.update(response) + + if attrs: + formatter = get_callable(settings.CAS_CUSTOM_ATTRIBUTES_FORMATER) + formatter(auth_success, attrs) if pgt: pgtElement = etree.SubElement(auth_success, CAS + 'proxyGrantingTicket')