Commit d8144390 authored by Culley Angus's avatar Culley Angus Committed by Zenon Mousmoulas

cleanups

parent 661042ab
......@@ -13,20 +13,22 @@ class shibauthBackend:
authsource = kwargs.get('authsource')
if authsource != 'shibboleth':
return None
try:
user = self._auth_user(username, firstname, lastname, mail)
except:
except Exception as e:
return None
if not user:
return None
return user
def _auth_user(self, username, firstname, lastname, mail):
try:
user = User.objects.get(username__exact=username)
# The user did not exist. Create one with no privileges
except:
except:
user = User.objects.create_user(username, mail, None)
user.first_name = firstname
user.last_name = lastname
......
......@@ -971,7 +971,7 @@ def overview(request):
context_instance=RequestContext(request))
else:
return HttpResponseRedirect(reverse("altlogin"))
@never_cache
......@@ -1019,48 +1019,42 @@ def manage_login(request,backend):
@never_cache
def user_login(request):
try:
error_username = False
error_orgname = False
error_entitlement = False
error_mail = False
has_entitlement = False
errors = []
error = ''
username = request.META['HTTP_EPPN']
if not username:
error_username = True
username = lookupShibAttr(settings.SHIB_USERNAME, request.META)
firstname = lookupShibAttr(settings.SHIB_FIRSTNAME, request.META)
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']
entitlement = request.META['HTTP_SHIB_EP_ENTITLEMENT']
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 username:
errors.append(_("Your idP should release the eduPersonPrincipalName attribute towards this service<br>"))
if settings.SHIB_AUTH_ENTITLEMENT:
if settings.SHIB_AUTH_ENTITLEMENT not in entitlement.split(";"):
errors.append(_("Your idP should release an appropriate eduPersonEntitlement attribute towards this service<br>"))
if not mail:
error_mail = True
if error_username:
error = _("Your idP should release the eduPersonPrincipalName attribute towards this service<br>")
if error_entitlement:
error = error + _("Your idP should release an appropriate eduPersonEntitlement attribute towards this service<br>")
if error_mail:
error = error + _("Your idP should release the mail attribute towards this service")
if error_username or error_orgname or error_entitlement or error_mail:
return render_to_response('status.html', {'error': error, "missing_attributes": True},
context_instance=RequestContext(request))
errors.append(_("Your idP should release the mail attribute towards this service"))
if errors:
error = ''.join(errors)
return render_to_response(
'status.html',
{'error': error, "missing_attributes": True},
context_instance=RequestContext(request)
)
try:
user = User.objects.get(username__exact=username)
user.email = mail
user.first_name = firstname
user.last_name = lastname
user.save()
user_exists = True
except User.DoesNotExist:
user_exists = False
pass
user = authenticate(username=username, firstname=firstname, lastname=lastname, mail=mail, authsource='shibboleth')
if user is not None:
try:
......@@ -1071,18 +1065,29 @@ def user_login(request):
form.fields['user'] = forms.ModelChoiceField(queryset=User.objects.filter(pk=user.pk), empty_label=None)
form.fields['institution'] = forms.ModelChoiceField(queryset=Institution.objects.all(), empty_label=None)
form.fields['email'] = forms.CharField(initial = user.email)
return render_to_response('registration/select_institution.html', {'form': form}, context_instance=RequestContext(request))
return render_to_response(
'registration/select_institution.html',
{'form': form},
context_instance=RequestContext(request)
)
if user.is_active:
login(request, user)
return HttpResponseRedirect(reverse("manage"))
else:
status = _("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") %user.username
return render_to_response('status.html', {'status': status, 'inactive': True},
context_instance=RequestContext(request))
return render_to_response(
'status.html',
{'status': status, 'inactive': True},
context_instance=RequestContext(request)
)
else:
error = _("Something went wrong during user authentication. Contact your administrator %s" %user)
return render_to_response('status.html', {'error': error,},
context_instance=RequestContext(request))
return render_to_response(
'status.html',
{'error': error,},
context_instance=RequestContext(request)
)
except Exception as e:
error = _("Invalid login procedure. Error: %s"%e)
return render_to_response('status.html', {'error': error,},
......
......@@ -17,7 +17,7 @@
<object pk="1" model="flatpages.flatpage">
<field type="CharField" name="url">/faq/en/</field>
<field type="CharField" name="title">Frequently Asked Questions</field>
<field type="TextField" name="content">&lt;p&gt;&lt;strong&gt;FAQ in English will soon apear here...&lt;/strong&gt;&lt;/p&gt;</field>
<field type="TextField" name="content">&lt;p&gt;&lt;strong&gt;Coming soon...&lt;/strong&gt;&lt;/p&gt;</field>
<field type="BooleanField" name="enable_comments">False</field>
<field type="CharField" name="template_name"></field>
<field type="BooleanField" name="registration_required">False</field>
......@@ -39,7 +39,7 @@
<object pk="4" model="flatpages.flatpage">
<field type="CharField" name="url">/what/en/</field>
<field type="CharField" name="title">The service - What is eduroam?</field>
<field type="TextField" name="content">&lt;p&gt;&lt;iframe src="http://www.youtube.com/embed/qk9aljqu20A?hl=el" width="560" height="315"&gt;&lt;/iframe&gt;&lt;/p&gt;
<field type="TextField" name="content">&lt;p&gt;&lt;iframe src="//www.youtube.com/embed/qk9aljqu20A?hl=el" width="560" height="315"&gt;&lt;/iframe&gt;&lt;/p&gt;
&lt;p&gt;eduroam (&lt;strong&gt;edu&lt;/strong&gt;cation&amp;nbsp;&lt;strong&gt;roam&lt;/strong&gt;ing) is the secure, world-wide roaming access service developed for the international research and education community.&lt;/p&gt;
&lt;p&gt;eduroam allows students, researchers and staff from participating institutions to obtain Internet connectivity across campus and when visiting other participating institutions by simply opening their laptop.&lt;/p&gt;</field>
<field type="BooleanField" name="enable_comments">False</field>
......@@ -47,4 +47,4 @@
<field type="BooleanField" name="registration_required">False</field>
<field to="sites.site" name="sites" rel="ManyToManyRel"><object pk="1"></object></field>
</object>
</django-objects>
\ No newline at end of file
</django-objects>
Ο λογαριασμός σας με όνομα χρήστη «{{user.username}}» ενεργοποιήθηκε.
Μπορείτε να χρησιμοποιήσετε την υπηρεσία eduroam management, κάνοντας login στην παρακάτω
διεύθυνση:
http://{{ site.domain }}{% url manage %}
---------------------------------------------------------------------------
Your account with username “{{ user.username }}” has been activated.
You may login to eduroam management using the following URL:
......
Ο/H {{ user.get_full_name }} έκανε αίτηση για νεό λογαριασμό στην υπηρεσία.
Όνομα χρήστη: {{ user.username }}
E-mail: {{ user.email }}
Φορέας: {{institution}}
Για να ενεργοποιήσετε το λογαριασμό και να επιτρέψετε στο χρήστη να
χρησιμοποιήσει την υπηρεσία, επισκεφθείτε τον ακόλουθο σύνδεσμο:
http://{{ site.domain }}{% url activate_account activation_key %}
Ο χρήστης θα ενημερωθεί για την ενεργοποίηση του λογαριασμού του μέσω e-mail.
-----------------------------------------------------------------------------
{{ user.get_full_name }} has registered for a new account.
Username: {{user.username}}
E-mail: {{user.email}}
Φορέας: {{institution}}
Institution: {{institution}}
To activate the user's account and allow them to access the service, click on
the following link:
......
......@@ -4,7 +4,7 @@
<div class="container-fluid">
<div class="row-fluid">
<div class="span3"></div>
<div class="span6">
<div class="hero-unit">
......@@ -13,7 +13,7 @@
<div class="span9">Institutional eduroam management</div>
</div>
<form class="form-horizontal" method="post" action="{% url login %}">
{% if form.non_field_errors %}
{% for err in form.non_field_errors %}
<div class="control-group error ">
......
......@@ -27,6 +27,9 @@
<div class="span7">
Excellent! You are a click away from getting into your institution eduroam management.
Select your institution to proceed. Our administrators will activate your account and notify you via e-mail.
Please do not continue if you are not the eduroam administrator for this institution.
Any inappropriate requests will be reported directly to the institution, along with your name and email.
</div>
<div class="span12"></div>
<div class="span12">
......@@ -62,7 +65,7 @@ Select your institution to proceed. Our administrators will activate your accoun
{% endif %} <span class="help-block"> {{ form.institution.help_text }}</span>
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" id="applybutton" value="Apply" class="btn btn-primary"/>
......@@ -79,5 +82,5 @@ Select your institution to proceed. Our administrators will activate your accoun
{% endblock %}
{% block subcontent %}
{% block subcontent %}
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment