Skip to content

Can't join a table with multiple relations and a unauthorized column #727

@sebj54

Description

@sebj54

Hi there!

This problem is hard to explain with a few words so I'll give you an example directly:

I have two tables: post and user. A post has two relations with the user table: author and moderator. In my app, everyone can see who is the author of a given post but only admins and moderators can see the user who has moderated the post.

So I'm using the authorization middleware to allow access to the moderator column, based on user's role (I do that with authorization.columnHandler).

Then, when I'm trying to list posts with a GET on /records/post?join=user, this error occurs:

{ "code":9999, "message":"Call to a member function getName() on null" }
X-Exception-File	[...]\vendor\mevdschee\php-crud-api\src\Tqdev\PhpCrudApi\Record\RelationJoiner.php:150 X-Exception-Message	Call to a member function getName() on null X-Exception-Name	Error 

I have a simple fix for that, see related PR.

⚠ I really don't know if my fix does not have any side effect.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions