Skip to content

Commit

Permalink
session issues
Browse files Browse the repository at this point in the history
  • Loading branch information
timbroder committed Dec 19, 2011
1 parent ed77471 commit f647cb2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
13 changes: 10 additions & 3 deletions django-app/articles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from django.utils.html import escape
import logging
from django.contrib import messages
from django.contrib.auth import authenticate, login, logout

debug = getattr(settings, 'DEBUG', None)

Expand Down Expand Up @@ -128,6 +129,7 @@ def post(request):
try:
profile = UserProfile.objects.get(auth_key=data['auth'])
except Exception as e:
logout(request)
logging.error('bad auth key', exc_info=True, extra={'request': request, 'exception': e})
return NottyResponse('bad auth key')

Expand Down Expand Up @@ -309,8 +311,9 @@ def share(request):
try:
profile = UserProfile.objects.get(auth_key=data['auth'])
except:
logout(request)
logging.error("bad auth key", exc_info=True, extra={'request': request })
return NottyResponse('bad auth key', spinner_off)
return NottyResponse('bad auth key, please check readersharing.net', spinner_off)

try:
article = get_entry_data(request, data['url'], data['auth'], data['sha'])
Expand Down Expand Up @@ -439,7 +442,7 @@ def comment(request):
profile = UserProfile.objects.get(auth_key=data['auth'])
except Exception as e:
logging.info("bad auth key", exc_info=True, extra={'request': request, 'exception': e})
return NottyResponse('bad auth key', remove_spinner)
return NottyResponse('bad auth key, please check readersharing.net', remove_spinner)

share_article(article, profile)
comment = add_comment(request, article, profile, data['comment'])
Expand Down Expand Up @@ -536,7 +539,6 @@ def contacts(request):
if not user.is_authenticated():
return r2r('login.html', {})
else:
request.session.set_expiry(1680)
if request.session.get('google_contacts_cached'):
contacts = request.session.get('google_contacts_cached')
else:
Expand All @@ -563,6 +565,11 @@ def home(request):
#logging.info('test', exc_info=True, extra={'request': request,})
return contacts(request)

def session_expires(request):
print "EXPIRE"
request.session.set_expiry(900)
return redirect('/')

def reader_subscribe(request, email):
#quickadd_url = "https://www.google.com/reader/api/0/subscription/edit?ck=%s&client=scroll" % time.time()
quickadd_url = "http://www.google.com/reader/api/0/subscription/quickadd?client=sscroll"
Expand Down
2 changes: 1 addition & 1 deletion django-app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def custom_show_toolbar(request):
'debug_toolbar.panels.logger.LoggingPanel',
)

LOGIN_REDIRECT_URL = '/'
LOGIN_REDIRECT_URL = '/accounts/expire'
LOGOUT_REDIRECT_URL = '/'
AUTH_PROFILE_MODULE = 'articles.UserProfile'

Expand Down
1 change: 1 addition & 0 deletions django-app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
(r'^comments/', include('django.contrib.comments.urls')),

(r'^follow/all/$', articles.followall),
(r'^accounts/expire/$', articles.session_expires),
(r'^follow/(?P<email>.+)/$', articles.follow),
(r'^unfollow/(?P<email>.+)/$', articles.unfollow),
(r'^shared/(?P<email>.+)/$', feeds.UsersSharedFeed()),
Expand Down

0 comments on commit f647cb2

Please sign in to comment.