Custom permissions and custom errors
I'm developing an application with the Garden framework and now I'm securing controllers actions using custom permissions.
class MyController extends Gdn_Controller { public function Index() { $this->Permission('MyApp.OneSecurityPermission'); ... } }
When I access to /myController with a role that don't has this permission I see this:
Can I customize this error page only for this controller action (not globally)?
There was an error rendering this rich post.
Tagged:
1
Comments
Yes
Gdn::Locale()->SetTranslation('PermissionErrorMessage',T('Your Message'));
grep is your friend.
Thank you @x00, but what I want is a custom page...
There was an error rendering this rich post.
grep is your friend.
@x00, your help is invaluable. I hope this can help many others developer.
There was an error rendering this rich post.
There is more than one way to shell an egg. You could make it a proper exception, then direct to a custom controller.
grep is your friend.
Here what I've done:
added this function to my application
bootstrap.php
then use this in every controller action:
So now I can show different pages for every action (and If I want I can use another master view as a parameter).
Thank you again @x00
There was an error rendering this rich post.
I think if you are making your own app you might well keep in house. You could create a base controller, for you app and extend that, or whatever.
grep is your friend.