Revision 1698da77 flowspec/views.py
b/flowspec/views.py | ||
---|---|---|
291 | 291 |
lastname = lookupShibAttr(settings.SHIB_LASTNAME, request.META) |
292 | 292 |
mail = lookupShibAttr(settings.SHIB_MAIL, request.META) |
293 | 293 |
entitlement = lookupShibAttr(settings.SHIB_ENTITLEMENT, request.META) |
294 |
organization = request.META['HTTP_SHIB_HOMEORGANIZATION'] |
|
294 |
#organization = request.META['HTTP_SHIB_HOMEORGANIZATION']
|
|
295 | 295 |
|
296 | 296 |
if settings.SHIB_AUTH_ENTITLEMENT in entitlement.split(";"): |
297 | 297 |
has_entitlement = True |
298 | 298 |
if not has_entitlement: |
299 | 299 |
error_entitlement = True |
300 |
if not organization: |
|
301 |
error_orgname = True |
|
300 |
# if not organization:
|
|
301 |
# error_orgname = True
|
|
302 | 302 |
if not mail: |
303 | 303 |
error_mail = True |
304 | 304 |
if error_username: |
305 | 305 |
error = _("Your idP should release the HTTP_EPPN attribute towards this service<br>") |
306 |
if error_orgname: |
|
307 |
error = error + _("Your idP should release the HTTP_SHIB_HOMEORGANIZATION attribute towards this service<br>") |
|
306 |
# if error_orgname:
|
|
307 |
# error = error + _("Your idP should release the HTTP_SHIB_HOMEORGANIZATION attribute towards this service<br>")
|
|
308 | 308 |
if error_entitlement: |
309 | 309 |
error = error + _("Your idP should release an appropriate HTTP_SHIB_EP_ENTITLEMENT attribute towards this service<br>") |
310 | 310 |
if error_mail: |
... | ... | |
324 | 324 |
user = authenticate(username=username, firstname=firstname, lastname=lastname, mail=mail, authsource='shibboleth') |
325 | 325 |
if user is not None: |
326 | 326 |
try: |
327 |
peer = Peer.objects.get(domain_name=organization) |
|
328 |
up = UserProfile.objects.get_or_create(user=user,peer=peer) |
|
327 |
peer = user.get_profile().peer |
|
328 |
# peer = Peer.objects.get(domain_name=organization) |
|
329 |
# up = UserProfile.objects.get_or_create(user=user,peer=peer) |
|
329 | 330 |
except: |
330 |
error = _("Your organization's domain name does not match our peers' domain names<br>Please contact Helpdesk to resolve this issue") |
|
331 |
return render_to_response('error.html', {'error': error}, context_instance=RequestContext(request)) |
|
331 |
form = UserProfileForm() |
|
332 |
form.fields['user'] = forms.ModelChoiceField(queryset=User.objects.filter(pk=user.pk), empty_label=None) |
|
333 |
form.fields['peer'] = forms.ModelChoiceField(queryset=Peer.objects.all(), empty_label=None) |
|
334 |
return render_to_response('registration/select_institution.html', {'form': form}, context_instance=RequestContext(request)) |
|
332 | 335 |
if not user_exists: |
333 | 336 |
user_activation_notify(user) |
334 | 337 |
if user.is_active: |
... | ... | |
407 | 410 |
return render_to_response('add_port.html', {'form': form,}, |
408 | 411 |
context_instance=RequestContext(request)) |
409 | 412 |
|
413 |
@never_cache |
|
414 |
def selectinst(request): |
|
415 |
if request.method == 'POST': |
|
416 |
request_data = request.POST.copy() |
|
417 |
user = request_data['user'] |
|
418 |
try: |
|
419 |
existingProfile = UserProfile.objects.get(user=user) |
|
420 |
error = _("Violation warning: User account is already associated with an institution.The event has been logged and our administrators will be notified about it") |
|
421 |
return render_to_response('error.html', {'error': error, 'inactive': True}, |
|
422 |
context_instance=RequestContext(request)) |
|
423 |
except UserProfile.DoesNotExist: |
|
424 |
pass |
|
425 |
|
|
426 |
form = UserProfileForm(request_data) |
|
427 |
if form.is_valid(): |
|
428 |
userprofile = form.save() |
|
429 |
user_activation_notify(userprofile.user) |
|
430 |
error = _("User account <strong>%s</strong> is pending activation. Administrators have been notified and will activate this account within the next days. <br>If this account has remained inactive for a long time contact your technical coordinator or GRNET Helpdesk") %userprofile.user.username |
|
431 |
return render_to_response('error.html', {'error': error, 'inactive': True}, |
|
432 |
context_instance=RequestContext(request)) |
|
433 |
else: |
|
434 |
form.fields['user'] = forms.ModelChoiceField(queryset=User.objects.filter(pk=user.pk), empty_label=None) |
|
435 |
form.fields['institution'] = forms.ModelChoiceField(queryset=Peer.objects.all(), empty_label=None) |
|
436 |
return render_to_response('registration/select_institution.html', {'form': form}, context_instance=RequestContext(request)) |
|
437 |
|
|
410 | 438 |
@login_required |
411 | 439 |
@never_cache |
412 | 440 |
def user_logout(request): |
Also available in: Unified diff