Browse Source

When user is already logged in redirect to the startpage

Florian Streibelt 7 years ago
parent
commit
e7043e2f08
2 changed files with 11 additions and 1 deletions
  1. 1
    1
      k4ever/main/urls.py
  2. 10
    0
      k4ever/main/views.py

+ 1
- 1
k4ever/main/urls.py View File

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

+ 10
- 0
k4ever/main/views.py View File

@@ -12,6 +12,8 @@ from django.db.models import Count, Max
12 12
 from django.http import HttpResponseRedirect
13 13
 from django.shortcuts import render_to_response
14 14
 from django.template import RequestContext
15
+from django.core.urlresolvers import reverse
16
+import django.contrib.auth.views
15 17
 
16 18
 from buyable.models import Purchase, Buyable, BuyableType
17 19
 from main.helper import getUserFromAuthblob
@@ -179,3 +181,11 @@ def pluginAuthblob(request, pluginId):
179 181
 	d['pluginmsg'] = "Authblob erfolgreich geändert"
180 182
 	return render_to_response("settings/settings.html", d, RequestContext(request))
181 183
 
184
+
185
+def login(request):
186
+	''' Login - redirect wenn schon angemeldet.
187
+	'''
188
+	if request.user.is_authenticated():
189
+		return HttpResponseRedirect(reverse('main.views.startpage'))
190
+	return django.contrib.auth.views.login(request)
191
+

Loading…
Cancel
Save