Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Login Customer after they reset their password
 
jlintott
Jr. Member
 
Total Posts:  7
Joined:  2012-11-21
 

I am trying to figure out how to log a customer in to their account following a password reset triggered by a forgotten password link.

Is there a setting in the admin or an event I could hook into.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Denys Babenko
Sr. Member
 
Avatar
Total Posts:  130
Joined:  2010-03-03
Fritz-Elsas-Str. 60
 

You could try hooking on “customer_save_after” event with code below. Please, note that it’s a guess and I haven’t tested it.

public function test()
    
{
        
try {
            $session 
Mage::getSingleton('customer/session');
            
$request Mage::app()->getRequest();

            if (!
$session->isLoggedIn() &&
                
$request->getQuery('id') &&
                
$request->getPost('password') &&
                
$request->getModuleName() == 'customer' &&
                
$request->getControllerName() == 'account' &&
                
$request->getActionName() == 'resetPasswordPost'{

                $customer 
Mage::getModel('customer/customer')
                    ->
setWebsiteId(Mage::app()->getStore()->getWebsiteId())
                    ->
load($request->getQuery('id'))
                ;

                if (!
$customer->getUsername()) {
                    
return $this;
                
}

                $session
->login($customer->getUsername(), $request->getPost('password'));
            
}
        } 
catch (Exception $e{
            Mage
::logException($e);
        
}
        
return $this;
    
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
jlintott
Jr. Member
 
Total Posts:  7
Joined:  2012-11-21
 

I initially hacked the core to do it in logoutSuccessAfter event. The solution you suggest is much more elegant. I will implement it and post back on how it goes.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top