Aimeos redirect backend with error

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
wassim.hattab
Posts: 20
Joined: 13 Jul 2016, 08:03

Aimeos redirect backend with error

Post by wassim.hattab » 26 Sep 2016, 08:27

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 2597 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?

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Aimeos redirect backend with error

Post by aimeos » 26 Sep 2016, 10:17

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.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

wassim.hattab
Posts: 20
Joined: 13 Jul 2016, 08:03

Re: Aimeos redirect backend with error

Post by wassim.hattab » 26 Sep 2016, 15:53

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?

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Aimeos redirect backend with error

Post by aimeos » 26 Sep 2016, 16:09

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
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply