def get_request_information():

    information = {}

    if has_request_context():
        information["request"] = {
            "api_endpoint_method": request.method,
            "api_endpoint": request.path,
            "ip": request.remote_addr,
            "platform": request.user_agent.platform,
            "browser": request.user_agent.browser,
            "browser_version": request.user_agent.version,
            "user_agent":request.user_agent.string
        }

        if api.auth.is_logged_in():

            user = api.user.get_user()
            team = api.user.get_team()
            groups = api.team.get_groups()

            information["user"] = {
                "username": user["username"],
                "email": user["email"],
                "team_name": team["team_name"],
                "school": team["school"],
                "groups": [group["name"] for group in groups]
            }

    return information
Returns a dictionary of contextual information about the user at the time of logging.
dataset/ETHPy150Open IceCTF/ctf-platform/api/api/logger.py/get_request_information