Created
June 24, 2016 15:40
-
-
Save ramuta/7b30a02d0a97cf4d645d1997c70e1463 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
from google.appengine.api import users | |
from webapp2 import redirect_to, redirect | |
def admin_required(handler): | |
def _check_login(self, *args, **kwargs): | |
user = users.get_current_user() | |
if user: | |
if not users.is_current_user_admin(): | |
return redirect_to("forbidden") | |
else: | |
return handler(self, *args, **kwargs) | |
else: | |
return self.redirect(users.create_login_url(self.request.uri)) | |
return _check_login |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment