public function isExpired($iUserId)
    {
        if (empty($iUserId)) {
            return false;
        }

        $oDb = Factory::service('Database');
        $oDb->select('u.password_changed,ug.password_rules');
        $oDb->where('u.id', $iUserId);
        $oDb->join(NAILS_DB_PREFIX . 'user_group ug', 'ug.id = u.group_id');
        $oDb->limit(1);
        $oResult = $oDb->get(NAILS_DB_PREFIX . 'user u');

        if ($oResult->num_rows() !== 1) {
            return false;
        }

        //  Decode the password rules
        $oGroupPwRules = json_decode($oResult->row()->password_rules);

        if (empty($oGroupPwRules->expiresAfter)) {
            return false;
        }

        $sChanged = $oResult->row()->password_changed;

        if (is_null($sChanged)) {

            return true;

        } else {

            $oThen     = new \DateTime($sChanged);
            $oNow      = new \DateTime();
            $oInterval = $oNow->diff($oThen);

            return $oInterval->days >= $oGroupPwRules->expiresAfter;
        }
    }