def authorization_required(is_admin=False):
    def decorator(func):
        @wraps(func)
        @coroutine
        def wrap(self, *args, **kwargs):
            io_loop = IOLoop.current()

            uid, remote_ip, start_time = self.get_secure_cookie('session', (None, None, None))
            if not all((uid, remote_ip, start_time)):
                raise Return(reject(self, 'Not authorized'))

            if not (start_time + SESSION_SECS) > io_loop.time():
                raise Return(reject(self, 'Session expired'))

            self.current_user = yield find_user(uid, is_admin=is_admin)

            if self.current_user.disabled:
                raise Return(reject(self, 'User disabled'))

            result = yield maybe_future(func(self, *args, **kwargs))
            raise Return(result)

        return wrap
    return decorator
dataset/ETHPy150Open mosquito/pypi-server/pypi_server/handlers/api/login.py/authorization_required/original