Commit dc16526f authored by Leonidas Poulopoulos's avatar Leonidas Poulopoulos

Major Login improvements

- Added a login welcome page that acts as the LOGIN_URL
- All logins are carried out via a login wrapper
- Translation changes
parent f7a38ae2
# -*- coding: utf-8 -*- vim:encoding=utf-8:
# vim: tabstop=4:shiftwidth=4:softtabstop=4:expandtab
from django.shortcuts import render_to_response,get_object_or_404
from django.shortcuts import render_to_response,get_object_or_404,redirect
from django.http import HttpResponse,HttpResponseRedirect,Http404
from django.template import RequestContext
from django.core.urlresolvers import reverse
from django.contrib.auth.decorators import login_required
from django.contrib.auth import logout
from edumanage.models import *
from accounts.models import *
from edumanage.forms import *
......@@ -37,6 +38,22 @@ from edumanage.decorators import social_active_required
def index(request):
return render_to_response('front/index.html', context_instance=RequestContext(request))
@never_cache
def manage_login_front(request):
user = request.user
try:
profile = user.get_profile()
except UserProfile.DoesNotExist:
return render_to_response('edumanage/welcome_manage.html',
context_instance=RequestContext(request, base_response(request)))
except AttributeError:
return render_to_response('edumanage/welcome_manage.html',
context_instance=RequestContext(request, base_response(request)))
if user.is_authenticated() and user.is_active and profile.is_social_active:
return redirect(reverse('manage'))
else:
return render_to_response('edumanage/welcome_manage.html',
context_instance=RequestContext(request, base_response(request)))
@login_required
@social_active_required
......@@ -990,6 +1007,15 @@ def get_all_services(request):
locs.append(response_location)
return HttpResponse(json.dumps(locs), mimetype='application/json')
@never_cache
def manage_login(request,backend):
logout(request)
qs = request.GET.urlencode()
qs = '?%s' % qs if qs else ''
if backend == 'shibboleth':
return redirect(reverse('login'))
return redirect(reverse('socialauth_begin', args=[backend])+qs)
@never_cache
def user_login(request):
try:
......
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.8\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-02-07 12:37+0200\n"
"POT-Creation-Date: 2013-02-07 16:01+0200\n"
"PO-Revision-Date: 2012-10-23 11:29+0300\n"
"Last-Translator: Leonidas Poulopoulos <leopoul@noc.grnet.gr>\n"
"Language-Team: Greek <leopoul@noc.grnet.gr>\n"
......@@ -38,8 +38,8 @@ msgstr "Helpdesk ΕΔΕΤ"
msgid "%sUser account activated"
msgstr ""
#: edumanage/decorators.py:18 edumanage/views.py:1053 edumanage/views.py:1076
#: edumanage/views.py:1127
#: edumanage/decorators.py:18 edumanage/views.py:1079 edumanage/views.py:1102
#: edumanage/views.py:1153
#, python-format
msgid ""
"User account <strong>%s</strong> is pending activation. Administrators have "
......@@ -163,35 +163,35 @@ msgid ""
"%(numid)s"
msgstr ""
#: edumanage/views.py:1021
#: edumanage/views.py:1047
msgid ""
"Your idP should release the eduPersonPrincipalName attribute towards this "
"service<br>"
msgstr ""
#: edumanage/views.py:1023
#: edumanage/views.py:1049
msgid ""
"Your idP should release an appropriate eduPersonEntitlement attribute "
"towards this service<br>"
msgstr ""
#: edumanage/views.py:1025
#: edumanage/views.py:1051
msgid "Your idP should release the mail attribute towards this service"
msgstr ""
#: edumanage/views.py:1057
#: edumanage/views.py:1083
#, python-format
msgid ""
"Something went wrong during user authentication. Contact your administrator "
"%s"
msgstr ""
#: edumanage/views.py:1061
#: edumanage/views.py:1087
#, python-format
msgid "Invalid login procedure. Error: %s"
msgstr "Λανθασμένη διαδικασία εισαγωγής στη διαχείριση. Σφάλμα: %s"
#: edumanage/views.py:1113
#: edumanage/views.py:1139
msgid ""
"Violation warning: User account is already associated with an institution."
"The event has been logged and our administrators will be notified about it"
......@@ -945,7 +945,8 @@ msgstr ""
msgid ""
"Administrators can login to management either via a social media account or "
"via Shibboleth: "
msgstr ""
msgstr "Οι διαχειριστές μπορούν να αποκτήσουν πρόσβαση στην εφαρμογή είτε με λογαριασμούς "
"social media είτε με Shibboleth:"
#: templates/front/management.html:17
msgid ""
......@@ -953,10 +954,12 @@ msgid ""
"The supported social media are depicted under the <b>manage</b> drop down "
"menu on top. Users can authenticate via their social media account. Once "
"they are activated they can manage their data"
msgstr ""
msgstr "Η διαχείριση μπορεί να πραγματοποιηθεί από χρήστες με λογαριασμούς social media."
"Τα social media που επιτρέπουν τη διαχείριση παρουσιάζονται κάτω από το μενού <b>Διαχείριση</b> στο "
"επάνω μέρος της σελίδας. Οι διαχειριστές ταυτοποιούνται με το social media λογαρισμό τους. Αφού "
"ενεργοποιηθούν, αποκτούν πρόσβαση στα δεδομένα του ιδρύματός τους"
#: templates/front/management.html:20
#, fuzzy
msgid ""
"The following are the requirements for admitting administrators to the "
"management application. Having fulfilled these, an administrator can log in "
......@@ -964,8 +967,8 @@ msgid ""
msgstr ""
"Τα ακόλουθα απαιτούνται για να αποκτήσει πρόσβαση ένας διαχειριστής στην "
"εφαρμογή. Έχοντας εκπληρώσει αυτές τις προϋποθέσεις ο διαχειριστής μπορεί να "
"συνδεθεί στην εφαρμογή χρησιμοποιώντας την επιλογή 'Διαχείριση' παρακάτω ή "
"την αντίστοιχη επιλογή από το μενού στο πάνω μέρος της σελίδας."
"συνδεθεί στην εφαρμογή χρησιμοποιώντας την επιλογή Shibboleth από από το μενού <b>Διαχείριση</b> στο "
"επάνω μέρος της σελίδας."
#: templates/front/management.html:23
msgid "Authentication and authorization are carried out through a"
......
......@@ -35,6 +35,12 @@ select {
width: 140px;
}
.btnlogin{
width: 70px;
height: 50px;
text-align: center;
}
.side-menu > li > a {
border: 1px solid #E5E5E5;
display: block;
......
{% extends "base.html" %} {% block content %}
<div class="container-fluid">
<div class="row-fluid">
<div class="span4"></div>
<div class="span4">
<div class="well">
<div class="row-fluid">
<div class="span12"><h3>Login</h3><hr></div>
</div>
<div class="row-fluid">
<div class="span12">
<a class="btn btnlogin" href="{% url manage_login 'shibboleth' %}"><img
src="/static/img/image_shibboleth_logo_color.png"
style="padding: 0px;"><br>Shibboleth</a>
<a class="btn btnlogin" href="{% url manage_login 'twitter' %}"><img
src="/static/img/twitter_img.png"
style="padding: 0px;"><br>Twitter</a>
<a class="btn btnlogin" href="{% url manage_login 'google' %}"><img
src="/static/img/google_img.png"
style="padding: 0px;"><br>Google</a>
</div>
</div>
</div>
</div>
<div class="span4"></div>
</div>
</div>
{% endblock %}
......@@ -5,17 +5,17 @@
</a>
<ul class="dropdown-menu loginoptions" role="menu"
aria-labelledby="drop2">
<li><a tabindex="-1" href="{% url manage %}">Shibboleth</a><img
<li><a tabindex="-1" href="{% url manage_login 'shibboleth' %}">Shibboleth</a><img
class="hidden-phone"
src="/static/img/image_shibboleth_logo_color.png"
style="padding: 0px;"></li>
<li><a tabindex="-1" href="{% url socialauth_begin 'twitter' %}">Twitter</a><img
<li><a tabindex="-1" href="{% url manage_login 'twitter' %}">Twitter</a><img
class="hidden-phone" src="/static/img/twitter_img.png"
style="padding: 0px;"></li>
{% comment %}<li><a tabindex="-1" href="{% url socialauth_begin 'facebook' %}">Facebook</a><img
{% comment %}<li><a tabindex="-1" href="{% url manage_login 'facebook' %}">Facebook</a><img
class="hidden-phone" src="/static/img/facebook_img.png"
style="padding: 0px;"></li>{% endcomment %}
<li><a tabindex="-1" href="{% url socialauth_begin 'google' %}">Google</a><img
<li><a tabindex="-1" href="{% url manage_login 'google' %}">Google</a><img
class="hidden-phone" src="/static/img/google_img.png"
style="padding: 0px;"></li>
{% comment %}<li><a tabindex="-1" href="{% url socialauth_begin 'linkedin' %}">LinkedIn</a><img
......
......@@ -16,6 +16,7 @@ urlpatterns = patterns('',
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
url(r'^managelogin/(?P<backend>[^/]+)/$', 'eduroam.edumanage.views.manage_login', name='manage_login'),
url(r'^login/?', 'eduroam.edumanage.views.user_login', name="login"),
url(r'^altlogin/?', 'django.contrib.auth.views.login', {'template_name': 'overview/login.html'}, name="altlogin"),
url(r'^logout/?', 'django.contrib.auth.views.logout', {'next_page': '/'}, name="logout"),
......@@ -43,7 +44,7 @@ urlpatterns += patterns('edumanage.views',
url(r'^usage/realm_data.xml', "realmdataxml", name="realmdataxml"),
url(r'^manage/?$', 'manage', name="manage"),
url(r'^manage/login/?$', 'manage_login_front', name="manage_login_front"),
url(r'^manage/institutions/?$', 'institutions', name="institutions"),
url(r'^manage/institution/edit/(?P<institution_pk>\d+)?$', 'add_institution_details', name="edit-institution"),
......
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