Jump to content

Recommended Posts

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!

 

  • 2 weeks later...

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.