Is there any way to use a Middleware that will intercept every request?
First of all, thanks for such a great forum.
We are using it and creating our custom application (addon) so wondering, is there any middleware available where we can perform our permission checks or any logic before passing control to controllers?
0
Comments
Is your custom addon a Vanilla addon? Then it is quite easy. You can use the events in the dispatcher for this. Look at
/library/core/class.dispatcher.phpfor detailed information. You can use it like that in your adddon:public function gdn_dispatcher_beforeDispatch_handler($sender, $args) { $request = $args['Request']; // See class.request.php for what you can do with that if ($this->checkbackWithGandalf($request->path(), Gdn::session()->User) !== true) { throw new Exception('Sorry, but Gandalf says you shall not pass...', 403); } // All good ... }Okay thanks, will try it out.