Skip to content

Instantly share code, notes, and snippets.

@mihasya
Created January 17, 2009 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mihasya/48451 to your computer and use it in GitHub Desktop.
Save mihasya/48451 to your computer and use it in GitHub Desktop.
#Copyright (c) 2009 Mikhail Panchenko
#MIT License http://www.opensource.org/licenses/mit-license.php
def userRequired(fn):
"""decorator for forcing a login"""
def new(*args, **kws):
user = users.get_current_user()
if not (user):
r = args[0]
return HttpResponseRedirect(users.create_login_url(
r.build_absolute_uri()))
else:
return fn(*args, **kws)
return new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment