diff --git a/ietf/ietfauth/urls.py b/ietf/ietfauth/urls.py index 6fd020807..891158f4e 100644 --- a/ietf/ietfauth/urls.py +++ b/ietf/ietfauth/urls.py @@ -1,11 +1,15 @@ # Copyright The IETF Trust 2007, 2009, All Rights Reserved from django.conf.urls import patterns, url +from django.contrib.auth.views import login urlpatterns = patterns('ietf.ietfauth.views', url(r'^$', 'index', name='account_index'), - url(r'^login/$', 'ietf_login'), +# url(r'^login/$', 'ietf_login'), + url(r'^login/$', login), + url(r'^logout/$', 'logout_view'), url(r'^loggedin/$', 'ietf_loggedin'), + url(r'^loggedout/$', 'logged_out'), url(r'^profile/$', 'profile'), # (r'^login/(?P[a-z0-9.@]+)/(?P.+)$', 'url_login'), url(r'^testemail/$', 'test_email'), diff --git a/ietf/ietfauth/views.py b/ietf/ietfauth/views.py index 69805b73f..4470f9e42 100644 --- a/ietf/ietfauth/views.py +++ b/ietf/ietfauth/views.py @@ -43,6 +43,7 @@ from django.shortcuts import render_to_response from django.contrib.auth import REDIRECT_FIELD_NAME, authenticate, login from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User +from django.contrib.auth.views import login, logout from django.utils.http import urlquote from django.utils.translation import ugettext as _ from django.core.exceptions import ValidationError @@ -63,6 +64,7 @@ def url_login(request, user, passwd): return HttpResponseRedirect('/accounts/loggedin/?%s=%s' % (REDIRECT_FIELD_NAME, urlquote(redirect_to))) return HttpResponse("Not authenticated?", status=500) +@login_required def ietf_login(request): if not request.user.is_authenticated(): return HttpResponse("Not authenticated?", status=500) @@ -259,3 +261,14 @@ def test_email(request): return r +def logout_view(request): + try: + logout(request) + return HttpResponseRedirect('/accounts/loggedout/') + except Warning as w: + from ietf.utils.log import log + log(w) + return HttpResponseRedirect('/accounts/loggedout/') + +def logged_out(request): + return render_to_response('registration/loggedout.html', {'next':'/'}, context_instance=RequestContext(request)) diff --git a/ietf/settings.py b/ietf/settings.py index 8667b4ce8..7d4bcbc6e 100644 --- a/ietf/settings.py +++ b/ietf/settings.py @@ -96,7 +96,7 @@ WSGI_APPLICATION = "ietf.wsgi.application" DAJAXICE_MEDIA_PREFIX = "dajaxice" -AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.RemoteUserBackend', ) +AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', ) #DATABASE_ROUTERS = ["ietf.legacy_router.LegacyRouter"] diff --git a/ietf/templates/base.html b/ietf/templates/base.html index f9025f31f..a3675af23 100644 --- a/ietf/templates/base.html +++ b/ietf/templates/base.html @@ -58,11 +58,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. {% if user %} -
{% if user.is_authenticated %} -{{ user }} -{% else %} -Sign In -{% endif %}
+
+ {% if request.get_full_path == "/accounts/loggedout/" %} + Sign In + {% else %} + {% if user.is_authenticated %} + {{ user }} | Sign Out + {% else %} + Sign In + {% endif %} + {% endif %} +
{% endif %} {% block start_content_table %} diff --git a/ietf/templates/registration/loggedout.html b/ietf/templates/registration/loggedout.html new file mode 100644 index 000000000..8bd2cd595 --- /dev/null +++ b/ietf/templates/registration/loggedout.html @@ -0,0 +1,11 @@ +{% extends "registration/base.html" %} + +{% block title %}Logged Out{% endblock %} + +{% block content %} +
+
+

You have been logged out

+
+
+{% endblock %} diff --git a/ietf/templates/registration/login.html b/ietf/templates/registration/login.html new file mode 100644 index 000000000..bfeb01603 --- /dev/null +++ b/ietf/templates/registration/login.html @@ -0,0 +1,19 @@ +{% extends "registration/base.html" %} + +{% block title %}Sign in{% endblock %} + +{% block content %} +
+
+

Sign In

+
{% csrf_token %} + + {{ form }} + +
+ +
+
+
+
+{% endblock %} diff --git a/static/css/base2.css b/static/css/base2.css index 80e850c1a..551f78441 100644 --- a/static/css/base2.css +++ b/static/css/base2.css @@ -404,3 +404,19 @@ span.fieldRequired { margin: 1em 0; } + +#login-pane { + width: 100%; + height: 100%; + // background: rgba(196,196,196,.5); +} + + +#login-form { + width: 24em; + padding: 2em; + margin-right: auto; + margin-left: auto; + margin-top: 10em; + background: white; +}