milesap Posted August 20, 2009 Share Posted August 20, 2009 Hello everyone, I would like to know the best way to approach this problem. I would like my website to check if a user has changed their password within say 4 weeks. If it hasn't been changed, I would like to change the requested controller and action to the change password controller / action. My question therefore is, where should I put this code? In the bootstrap, register a plugin, or another solution? Also, how could I change the controller and action that is displayed to the user if they are required to change their password? Should they be forwarded to the change password controller / action, or can you change the controller / action after dispatch to the change password controller / action? So if a user was on their profile page, but their password is no longer valid I would like to display the change password form instead of their profile. I would prefer the website to check if the password has expired for every page request, and not just during login. I know this is less efficient, however in the future I would like to use this same concept to check for other conditions which may change while the user is logged in. Any help would be much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/171171-best-way-to-change-controller-and-action/ Share on other sites More sharing options...
Zyx Posted August 31, 2009 Share Posted August 31, 2009 I'd write a plugin and overwrite the dispatchLoopStartup() method: class My_Controller_Plugin_Password extends Zend_Controller_Plugin_Abstract { public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { if(passwordNeedsToBeChanged()) { $request->setControllerName('auth'); $request->setActionName('password'); } } // end dispatchLoopStartup(); } // end My_Controller_Plugin_Password; Note that your plugin does not have to check, if we are in the password change action or not, because dispatchLoopStartup() is not called again after modifying the $request object. Quote Link to comment https://forums.phpfreaks.com/topic/171171-best-way-to-change-controller-and-action/#findComment-909580 Share on other sites More sharing options...
trq Posted August 31, 2009 Share Posted August 31, 2009 You might want to mention the framework your using. Quote Link to comment https://forums.phpfreaks.com/topic/171171-best-way-to-change-controller-and-action/#findComment-909620 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.