import functools


def authenticated(method):
    """Decorate with this method to restrict to authenticated user."""
    @functools.wraps(method)
    def wrapper(self, *args, **kwargs):
        if not self.current_user:
            self.redirect(self.settings["login_url"])
            return
        else:
            return method(self, *args, **kwargs)
    return wrapper