Created
January 17, 2009 20:53
-
-
Save mihasya/48451 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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