Stopping workflow - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Stopping workflow (/showthread.php?tid=31796) |
Stopping workflow - El Forum - 07-01-2010 [eluser]Dark$hadow[/eluser] Hi all, First of all, sorry for my english, I'm french... I use hooks at 'post_controller_constructor' level to control user is logged in before do any action and I would like to be able to stop the workflow immediately if user isn't logged. I know it's possible to do a redirection but it's not what I want (because of ajax requests). Here is my code (last instruction doesn't work): Code: if ($this->CI->input->post('method') == 'ajax') { I simply search a way to say "stop there and render immediately without passing in the called controller". Many thanks by advice for your answers. Dark. Stopping workflow - El Forum - 07-01-2010 [eluser]Buso[/eluser] from the userguide: Quote:post_controller I don't think that will give you any security (if that is what you are after). You should think about using a pre_controller hook, or check for permissions inside the controller constructor. I use this function to stop worflow + display output, but I execute it inside a controller: Code: public function _end() { Stopping workflow - El Forum - 07-01-2010 [eluser]danmontgomery[/eluser] He's using post_controller_constructor, not post_controller. There's no reason you can't do what you're already doing, just add an exit() after _display(). You'll lost the post_system hook this way, and CI calls db->close() after _display, so if you're using persistent connections you would want to manually close those. Stopping workflow - El Forum - 07-01-2010 [eluser]Buso[/eluser] My mistake Stopping workflow - El Forum - 07-01-2010 [eluser]Dark$hadow[/eluser] Wonderful noctrum solutions seems to work like a charm Here is the final code: Code: if ($this->CI->input->post('method') == 'ajax') { |