예제 #1
0
async def create_conversation(request, recv):
    head_block = await utils.get_request_block(request)
    recommended_resource = await roles_query.fetch_recommended_resource(
        request.app.config.DB_CONN, recv.get("user_id"), head_block.get("num"))
    await create_event(request, recv, "token",
                       utils.extract_request_token(request))
    await create_event(request, recv, "resource_name",
                       recommended_resource.get("name"))
    await create_event(request, recv, "resource_id",
                       recommended_resource.get("role_id"))
예제 #2
0
async def update_tracker(request, recv):
    if recv.get("approver_id"):
        head_block = await utils.get_request_block(request)
        owner_resource = await users_query.fetch_user_resource(
            request.app.config.DB_CONN, recv.get("approver_id"),
            head_block.get("num"))
        await create_event(request, recv, "approver_name",
                           owner_resource.get("name"))
    await create_event(request, recv, "token",
                       utils.extract_request_token(request))
예제 #3
0
 async def decorated_function(request, *args, **kwargs):
     try:
         id_dict = deserialize_api_key(
             request.app.config.SECRET_KEY, utils.extract_request_token(request)
         )
         await get_auth_by_next_id(id_dict.get("id"))
     except (ApiNotFound, BadSignature):
         raise ApiUnauthorized("Unauthorized: Invalid bearer token")
     response = await func(request, *args, **kwargs)
     return response
예제 #4
0
async def update_tracker(request, recv):
    """Update the chatbot tracker."""
    if recv.get("approver_id"):

        conn = await create_connection()
        owner_resource = await users_query.fetch_user_resource_summary(
            conn, recv.get("approver_id"))
        await create_event(request, recv, "approver_name",
                           owner_resource.get("name"))
    await create_event(request, recv, "token",
                       utils.extract_request_token(request))
예제 #5
0
async def update_tracker(request, recv):
    """Update the chatbot tracker."""
    if recv.get("approver_id"):
        owner_resource = await users_query.fetch_user_resource_summary(
            request.app.config.DB_CONN, recv.get("approver_id")
        )
        await create_event(
            request, recv.get("next_id"), "approver_name", owner_resource.get("name")
        )
    if recv.get("resource_id"):
        LOGGER.info("[Chatbot] %s: Updating tracker token", recv.get("next_id"))
        await create_event(
            request, recv.get("next_id"), "token", utils.extract_request_token(request)
        )
async def update_tracker(request, recv):
    """Update the chatbot tracker."""
    if recv.get("approver_id"):

        conn = await db_utils.create_connection(
            request.app.config.DB_HOST,
            request.app.config.DB_PORT,
            request.app.config.DB_NAME,
        )

        head_block = await utils.get_request_block(request)
        owner_resource = await users_query.fetch_user_resource_summary(
            conn, recv.get("approver_id"))
        await create_event(request, recv, "approver_name",
                           owner_resource.get("name"))
    await create_event(request, recv, "token",
                       utils.extract_request_token(request))
예제 #7
0
        async def decorated_function(request, *args, **kwargs):
            try:
                id_dict = deserialize_api_key(
                    request.app.config.SECRET_KEY, utils.extract_request_token(request)
                )

                conn = await db_utils.create_connection(
                    request.app.config.DB_HOST,
                    request.app.config.DB_PORT,
                    request.app.config.DB_NAME,
                )

                await auth_query.fetch_info_by_user_id(conn, id_dict.get("id"))

                conn.close()

            except (ApiNotFound, BadSignature):
                raise ApiUnauthorized("Unauthorized: Invalid bearer token")
            response = await func(request, *args, **kwargs)
            return response