Skip to content

Instantly share code, notes, and snippets.

@chriskief

chriskief/mixins.py

Created Oct 24, 2013
Embed
What would you like to do?
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
class RequireSignIn(object):
def dispatch(self, request, *args, **kwargs):
if not request.user.is_authenticated():
url = '{0}?next={1}'.format(reverse('signin'), request.path)
return HttpResponseRedirect(url)
return super(RequireSignIn, self).dispatch(request, *args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment