My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 70 attachment: 0001-When-user-is-not-authenticated-redirect-to-login-pa.patch (1.5 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
From 8a93fff616b2c8fef38b85bd31c1e91f5f917767 Mon Sep 17 00:00:00 2001
From: Alcides Fonseca <me@alcidesfonseca.com>
Date: Sat, 1 Aug 2009 22:22:40 +0100
Subject: [PATCH 1/3] When user is not authenticated, redirect to login page (expects django-accounts)

---
views.py | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/views.py b/views.py
index 99408cf..3ca9a36 100644
--- a/views.py
+++ b/views.py
@@ -95,7 +95,7 @@ def reply(request, thread):
to a thread. Note we don't have "nested" replies at this stage.
"""
if not request.user.is_authenticated():
- return HttpResponseServerError()
+ return HttpResponseRedirect('/accounts/login/?next=%s' % request.path)
t = get_object_or_404(Thread, pk=thread)
if t.closed:
return HttpResponseServerError()
@@ -176,7 +176,7 @@ def newthread(request, forum):
Only allows a user to post if they're logged in.
"""
if not request.user.is_authenticated():
- return HttpResponseServerError()
+ return HttpResponseRedirect('/accounts/login/?next=%s' % request.path)

f = get_object_or_404(Forum, slug=forum)

@@ -221,7 +221,7 @@ def updatesubs(request):
Allow users to update their subscriptions all in one shot.
"""
if not request.user.is_authenticated():
- return HttpResponseForbidden(_('Sorry, you need to login.'))
+ return HttpResponseRedirect('/accounts/login/?next=%s' % request.path)

subs = Subscription.objects.select_related().filter(author=request.user)

--
1.6.1.2

Powered by Google Project Hosting