lastname = lookupShibAttr(settings.SHIB_LASTNAME, request.META)
mail = lookupShibAttr(settings.SHIB_MAIL, request.META)
entitlement = lookupShibAttr(settings.SHIB_ENTITLEMENT, request.META)
- organization = request.META['HTTP_SHIB_HOMEORGANIZATION']
+ #organization = request.META['HTTP_SHIB_HOMEORGANIZATION']
if settings.SHIB_AUTH_ENTITLEMENT in entitlement.split(";"):
has_entitlement = True
if not has_entitlement:
error_entitlement = True
- if not organization:
- error_orgname = True
+# if not organization:
+# error_orgname = True
if not mail:
error_mail = True
if error_username:
error = _("Your idP should release the HTTP_EPPN attribute towards this service<br>")
- if error_orgname:
- error = error + _("Your idP should release the HTTP_SHIB_HOMEORGANIZATION attribute towards this service<br>")
+# if error_orgname:
+# error = error + _("Your idP should release the HTTP_SHIB_HOMEORGANIZATION attribute towards this service<br>")
if error_entitlement:
error = error + _("Your idP should release an appropriate HTTP_SHIB_EP_ENTITLEMENT attribute towards this service<br>")
if error_mail:
except:
user_exists = False
user = authenticate(username=username, firstname=firstname, lastname=lastname, mail=mail, authsource='shibboleth')
+
if user is not None:
try:
- peer = Peer.objects.get(domain_name=organization)
- up = UserProfile.objects.get_or_create(user=user,peer=peer)
+ peer = user.get_profile().peer
+# peer = Peer.objects.get(domain_name=organization)
+# up = UserProfile.objects.get_or_create(user=user,peer=peer)
except:
- error = _("Your organization's domain name does not match our peers' domain names<br>Please contact Helpdesk to resolve this issue")
- return render_to_response('error.html', {'error': error}, context_instance=RequestContext(request))
+ form = UserProfileForm()
+ form.fields['user'] = forms.ModelChoiceField(queryset=User.objects.filter(pk=user.pk), empty_label=None)
+ form.fields['peer'] = forms.ModelChoiceField(queryset=Peer.objects.all(), empty_label=None)
+ return render_to_response('registration/select_institution.html', {'form': form}, context_instance=RequestContext(request))
if not user_exists:
user_activation_notify(user)
if user.is_active:
error = _("Something went wrong during user authentication. Contact your administrator")
return render_to_response('error.html', {'error': error,},
context_instance=RequestContext(request))
- except Exception as e:
+ except User.DoesNotExist as e:
error = _("Invalid login procedure. Error: %s" %e)
return render_to_response('error.html', {'error': error,},
context_instance=RequestContext(request))
return render_to_response('add_port.html', {'form': form,},
context_instance=RequestContext(request))
+@never_cache
+def selectinst(request):
+ if request.method == 'POST':
+ request_data = request.POST.copy()
+ user = request_data['user']
+ try:
+ existingProfile = UserProfile.objects.get(user=user)
+ error = _("Violation warning: User account is already associated with an institution.The event has been logged and our administrators will be notified about it")
+ return render_to_response('error.html', {'error': error, 'inactive': True},
+ context_instance=RequestContext(request))
+ except UserProfile.DoesNotExist:
+ pass
+
+ form = UserProfileForm(request_data)
+ if form.is_valid():
+ userprofile = form.save()
+ user_activation_notify(userprofile.user)
+ 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
+ return render_to_response('error.html', {'error': error, 'inactive': True},
+ context_instance=RequestContext(request))
+ else:
+ form.fields['user'] = forms.ModelChoiceField(queryset=User.objects.filter(pk=user.pk), empty_label=None)
+ form.fields['institution'] = forms.ModelChoiceField(queryset=Peer.objects.all(), empty_label=None)
+ return render_to_response('registration/select_institution.html', {'form': form}, context_instance=RequestContext(request))
+
+@never_cache
+def overview(request):
+ user = request.user
+ if user.is_authenticated():
+ if user.has_perm('accounts.overview'):
+ users = User.objects.all()
+ group_routes = Route.objects.all()
+ return render_to_response('overview/index.html', {'users': users, 'routes': group_routes},
+ context_instance=RequestContext(request))
+ else:
+ violation=True
+ return render_to_response('overview/index.html', {'violation': violation},
+ context_instance=RequestContext(request))
+ else:
+ return HttpResponseRedirect(reverse("altlogin"))
+
@login_required
@never_cache
def user_logout(request):
def lookupShibAttr(attrmap, requestMeta):
for attr in attrmap:
- if attr in requestMeta:
- return requestMeta[attr]
- return ''
\ No newline at end of file
+ if (attr in requestMeta.keys()):
+ if len(requestMeta[attr]) > 0:
+ return requestMeta[attr]
+ return ''