func (m *Module) IsCreateOpAuthorised(ctx context.Context, project, dbAlias, col, token string, req *model.CreateRequest) (model.RequestParams, error) {
	m.RLock()
	defer m.RUnlock()
	rule, auth, err := m.authenticateCrudRequest(ctx, project, dbAlias, col, token, model.Create)
	if err != nil {
		return model.RequestParams{}, err
	}
	if auth != nil {
		if id, p := auth["id"]; p && id == utils.InternalUserID {
			hookResponse := m.integrationMan.InvokeHook(ctx, model.RequestParams{
				Claims:     auth,
				Resource:   "internal-api-access",
				Op:         "db-create",
				Attributes: map[string]string{"project": project},
			})
			if hookResponse.CheckResponse() {
				attr := map[string]string{"project": project, "db": dbAlias, "col": col}
				return model.RequestParams{Claims: auth, Resource: "db-create", Op: "access", Attributes: attr}, hookResponse.Error()
			}
		}
	}
	args := map[string]interface{}{"op": req.Operation, "auth": auth, "token": token}
	var rows []interface{}
	switch req.Operation {
	case utils.One:
		rows = []interface{}{req.Document}
	case utils.All:
		rows = req.Document.([]interface{})
	default:
		rows = []interface{}{}
	}
	for _, row := range rows {
		args["doc"] = row
		_, err := m.matchRule(ctx, project, rule, map[string]interface{}{"args": args}, auth, model.ReturnWhereStub{})
		if err != nil {
			return model.RequestParams{}, err
		}
	}
	attr := map[string]string{"project": project, "db": dbAlias, "col": col}
	return model.RequestParams{Claims: auth, Resource: "db-create", Op: "access", Attributes: attr}, nil
}
IsCreateOpAuthorised checks if the crud operation is authorised
package auth
import (
	"context"
	"fmt"
	"github.com/spaceuptech/helpers"
	"github.com/spaceuptech/space-cloud/gateway/config"
	"github.com/spaceuptech/space-cloud/gateway/model"
	"github.com/spaceuptech/space-cloud/gateway/utils"
)