Revision ca828a10 snf-astakos-app/astakos/im/target/shibboleth.py
b/snf-astakos-app/astakos/im/target/shibboleth.py | ||
---|---|---|
35 | 35 |
from django.utils.translation import ugettext as _ |
36 | 36 |
from django.contrib import messages |
37 | 37 |
from django.template import RequestContext |
38 |
from django.forms.models import inlineformset_factory |
|
38 | 39 |
|
39 | 40 |
from astakos.im.util import prepare_response, get_context, get_invitation |
40 | 41 |
from astakos.im.views import requires_anonymous, render_response |
41 | 42 |
from astakos.im.settings import DEFAULT_USER_LEVEL |
42 |
from astakos.im.models import AstakosUser, Invitation |
|
43 |
from astakos.im.models import AstakosUser, Invitation, AdditionalMail
|
|
43 | 44 |
from astakos.im.forms import LoginForm |
44 | 45 |
from astakos.im.activation_backends import get_backend, SimpleBackend |
45 | 46 |
|
... | ... | |
52 | 53 |
SHIB_DISPLAYNAME = "HTTP_SHIB_INETORGPERSON_DISPLAYNAME" |
53 | 54 |
SHIB_EP_AFFILIATION = "HTTP_SHIB_EP_AFFILIATION" |
54 | 55 |
SHIB_SESSION_ID = "HTTP_SHIB_SESSION_ID" |
56 |
SHIB_MAIL = "HTTP_SHIB_MAIL" |
|
55 | 57 |
|
56 | 58 |
@requires_anonymous |
57 | 59 |
def login(request, backend=None, on_login_template='im/login.html', on_creation_template='im/third_party_registration.html', extra_context={}): |
... | ... | |
72 | 74 |
return HttpResponseBadRequest("Missing user name in request") |
73 | 75 |
|
74 | 76 |
affiliation = tokens.get(Tokens.SHIB_EP_AFFILIATION, '') |
77 |
email = tokens.get(Tokens.SHIB_MAIL, None) |
|
75 | 78 |
|
76 | 79 |
try: |
77 | 80 |
user = AstakosUser.objects.get(provider='shibboleth', third_party_identifier=eppn) |
... | ... | |
88 | 91 |
context_instance=RequestContext(request)) |
89 | 92 |
except AstakosUser.DoesNotExist, e: |
90 | 93 |
user = AstakosUser(third_party_identifier=eppn, realname=realname, |
91 |
affiliation=affiliation, provider='shibboleth') |
|
94 |
affiliation=affiliation, provider='shibboleth', |
|
95 |
email=email) |
|
92 | 96 |
try: |
93 | 97 |
if not backend: |
94 | 98 |
backend = get_backend(request) |
... | ... | |
96 | 100 |
except Exception, e: |
97 | 101 |
form = SimpleBackend(request).get_signup_form(provider='shibboleth', instance=user) |
98 | 102 |
messages.add_message(request, messages.ERROR, e) |
99 |
form.data.update({'third_party_identifier':eppn, 'realname':realname, |
|
100 |
'affiliation':affiliation}) |
|
101 | 103 |
return render_response(on_creation_template, |
102 | 104 |
signup_form = form, |
103 | 105 |
provider = 'shibboleth', |
Also available in: Unified diff