Missing column user_id in table Users while checking ownership permissions for user

I got this error when i set Owner method in permission file
[
‘role’=>‘user’,
‘controller’=>[‘Users’],
‘action’=>[‘edit’,‘delete’],
‘allowed’=>new Owner()
]

In user table i set memberid instead id. id column also exist in user as primary key but memberid is also there just random number generate before save into database. memberid save as foreign key in department table like user_id and event i set memberid as primary key in user table $this->setPrimaryKey(‘memberid’) like this. but got error during i edit user and department record…Missing column user_id in table Users while checking ownership permissions for user.
Because RBAC plugin compare with ID not WIth memberid so please tell me to set memberid instead id for RBAC

yes it error must must throw by cakedc/auth plugin because plugin could not verify which column match with requesting param, so you have to define column
let me show how it will be config:-
[
‘role’=>‘user’,
‘controller’=>[‘Users’],
‘action’=>[‘edit’,‘delete’],
‘allowed’=>new Owner([
‘ownerForeignKey’=>‘user_id’ // or any column you want show check as foreignkey
])
],
you can define many configuration into Owner method, even you can define anonymous function for compare complex query or permissions… I hope it will work you daryl

1 Like

thank you so much for reply and let me give suggestion @shaan007. Yes now I have got some good response from usercontroller and I defined column key and everything work fine. Once Again thanks @shaan007. You looks so handsome :cupid: :heart_eyes: :kissing_heart:

thank you very much @daryl its my pleasure. :love_you_gesture: