Page 1 of 1

Aimeos redirect backend with error

Posted: 26 Sep 2016, 08:27
by wassim.hattab
Hello,
i'm trying to set permission to the admin in the expert mode so he cannot change or add or delete a catalog i just want to let him to add a product to a catalog so i saw the request that is sent to do action and i realized that there is different method name sent either insertItems or save items or...
i created a new permission in my backend
and in the do action i'm verifying if this admin has access to modify catalog but i can't find a way to redirect him back
aimeospermission.jpg
aimeospermission.jpg (36.97 KiB) Viewed 2599 times
but i'm getting error and it's keep loading and if i remove the output and send an empty array it gave me error undefined variazble output and if i delete the array it's also giving me an error
Any recommendation?

Re: Aimeos redirect backend with error

Posted: 26 Sep 2016, 10:17
by aimeos
You can only return an error object for JSON RPC calls, redirects won't have any effects (it's AJAX).

If you want to allow only adding products to categories, the simple admin interface can do this as well (in the product detail view). This would be much easier.

Re: Aimeos redirect backend with error

Posted: 26 Sep 2016, 15:53
by wassim.hattab
ok i added
throw new \Exception( 'You do not have permission to the folowing action!' );

But it's not showing as alert like other exceptions it's showing in the inspect element network
is there a method to show the exception as alert?

Re: Aimeos redirect backend with error

Posted: 26 Sep 2016, 16:09
by aimeos
Throwing an exception in the Laravel code doesn't transform into a JSON RPC error message. You have to build and return a JSON response yourself. Use this code as example: https://github.com/aimeos/ai-admin-exta ... c.php#L157