For this you need to use an observer which gets called on the controller_action_predispatch event and check if the customer is logged in or not and if customer is logged in check for your password expiration condition and redirect to customers dashboard.
you can use the following files for your reference.
1) app\etc\modules\TutsPlus_Demo.xml
<?xml version="1.0" encoding="UTF-8" ?>
<config>
<modules>
<TutsPlus_Demo>
<active>true</active>
<codePool>local</codePool>
</TutsPlus_Demo>
</modules>
</config>
2) app\code\local\TutsPlus\Demo\etc\config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<config>
<global>
<models>
<tutsplus_demo>
<class>TutsPlus_Demo_Model</class>
</tutsplus_demo>
</models>
</global>
<frontend>
<events>
<controller_action_predispatch>
<observers>
<tutsplus_demo>
<type>model</type>
<class>tutsplus_demo/observer</class>
<method>checkLogin</method>
</tutsplus_demo>
</observers>
</controller_action_predispatch>
</events>
</frontend>
</config>
3) app\code\local\TutsPlus\Demo\Model\Observer.php
<?php
class TutsPlus_Demo_Model_Observer
{
public function checkLogin(Varien_Event_Observer $observer)
{
$controller = strtolower(Mage::app()->getRequest()->getControllerName());
if(Mage::helper('customer')->isLoggedIn()){
if ($controller == 'account') {
return $this; //if in allowed actions do nothing.
} else {
//Your password expiration code goes here
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('customer/account/index'));
}
}
return $this;
}
}
Hope this will help you.