Skip to content

Filter results if joined table has an authorization.recordHandler #1009

Open
@chattago2002

Description

@chattago2002

Hi.
I'm trying to have good results from a call with join and filters.

I have 2 tables: "requests_details" and "requests". For the "requests" table I set the "authorization.recordHandler" middleware to add "filter=user_id,eq,$_SESSION['apiUser']['id']" if the user is not "admin".

The API endpoint is "/records/requests_details?join=requests&filter=request_id,nis".

At the moment I have the following response:

{
    "records": [
        {
            "id": 75,
            "request_id": null,
            "full_name": "John Doe",
            "phone": "00390099888",
            "room": "single"
        },
        {
            "id": 219,
            "request_id": {
                "id": 41,
                "full_name": "Melvin Carr",
                "birthday": "1960-06-27",
                "email": "MelvinRCarr@rhyta.com",
                "user_id": 128
            },
            "full_name": "Melvin Carr",
            "phone": "0039444777",
            "room": "double"
        }
    ]
}

For good results I mean those where request_id is not null.
I set "authorization.recordHandler" additional as following:

if ($tableName === 'requests_details') { return ($tableName == 'requests_details') ? 'filter=request_id,nis' : ''; } `

Where I'm wrong?
Is there another way to achieve the desired result?

Thanks

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions