Users

webapp2_extras.appengine.users.login_required(handler_method)[source]

A decorator to require that a user be logged in to access a handler.

To use it, decorate your get() method like this:

@login_required
def get(self):
    user = users.get_current_user(self)
    self.response.out.write('Hello, ' + user.nickname())

We will redirect to a login page if the user is not logged in. We always redirect to the request URI, and Google Accounts only redirects back as a GET request, so this should not be used for POSTs.

webapp2_extras.appengine.users.admin_required(handler_method)[source]

A decorator to require that a user be an admin for this application to access a handler.

To use it, decorate your get() method like this:

@admin_required
def get(self):
    user = users.get_current_user(self)
    self.response.out.write('Hello, ' + user.nickname())

We will redirect to a login page if the user is not logged in. We always redirect to the request URI, and Google Accounts only redirects back as a GET request, so this should not be used for POSTs.

Previous topic

User Models

Next topic

webapp2 features

This Page