When user is already logged in redirect to the startpage

This commit is contained in:
Florian Streibelt 2012-09-25 19:18:49 +02:00 committed by tkroenert
parent f43a06d7d9
commit e7043e2f08
2 changed files with 11 additions and 1 deletions

View File

@ -13,7 +13,7 @@ from django.conf import settings
urlpatterns = patterns('',
(r'^$', 'django.views.generic.simple.redirect_to', {'url': 'login/'}),
(r'^register/$', 'main.views.register'),
(r'^login/$', 'django.contrib.auth.views.login'),
(r'^login/$', 'main.views.login'),
(r'^logout/$', 'django.contrib.auth.views.logout',
{'template_name': 'registration/logout.html',
'next_page': '/user/login/'}),

View File

@ -12,6 +12,8 @@ from django.db.models import Count, Max
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.core.urlresolvers import reverse
import django.contrib.auth.views
from buyable.models import Purchase, Buyable, BuyableType
from main.helper import getUserFromAuthblob
@ -179,3 +181,11 @@ def pluginAuthblob(request, pluginId):
d['pluginmsg'] = "Authblob erfolgreich geändert"
return render_to_response("settings/settings.html", d, RequestContext(request))
def login(request):
''' Login - redirect wenn schon angemeldet.
'''
if request.user.is_authenticated():
return HttpResponseRedirect(reverse('main.views.startpage'))
return django.contrib.auth.views.login(request)