Login-GroceryCrud icon indicating copy to clipboard operation
Login-GroceryCrud copied to clipboard

**id_only** allows to modify others id via url :(

Open mcbcrud opened this issue 6 years ago • 4 comments

First of all congratulations for this great project, it has been very useful for me thanks!! ... the problem occurs when entering the table crud_users with a user with permission ID_ONLY, when entering edit, it is possible to modify the url with the id of another user and change the password .... screenshot_1


screenshot_2


screenshot_3

any suggestions???? greetings from Chile!!!

mcbcrud avatar Oct 25 '18 05:10 mcbcrud

Hi and thanks :)

You can use the getState() event to catch where the user is into, then you can use the $crud = $this->login_model->check($crud,"author"); in the crud part to avoid user to see other user's profile.

With $crud->getState()=="edit" you can make a database query to see if the permission is "IDOnly" for that page like extractPermission("ID",false,"crud_users") or with the more simple IDOnly("crud_users") and then you can redirect the user if the getStateInfo()->primary_key is different from the logged user's id.

I think is simple but a little tricky, but you can take a look at the wiki HERE and find YOUR better way to create it. I've give you more than 1 way to make it so I'm sure you'll find how to make it ;)

BTW! I suggest you to take the crud_users page just for you and create a new page for them, just to avoid to cut you off from the user management.

portapipe avatar Oct 25 '18 08:10 portapipe

the only way you can do it:

if($crud->getState()=="edit"){ $segmentsCount = $this->uri->total_segments(); $itemID = intval($this->uri->segment($segmentsCount)); if($itemID!=$this->idUsuario) redirect("/login/logout"); }

getStateInfo()->primary_key //Not work!!!

regards!!!

mcbcrud avatar Oct 27 '18 03:10 mcbcrud

Well make a var_dump($crud->getStateInfo()); and you'll see. Here the docs

portapipe avatar Oct 27 '18 11:10 portapipe

Yes, today it worked for me, yesterday I did not x) thanks!!!

mcbcrud avatar Oct 27 '18 15:10 mcbcrud