XF 1.5 Issue using PreDispatch Event Listener

JohnLogar

Active member
Hi,
I hope everyone is doing great, I'm facing an issue while using PreDispatch Listener on Public Route same like two factor authentication. I want to check a specfic condition on each request and return to a specific route if not meet the condition.

Here is my code in PreDispatch function

PHP:
      if ($userId) {
            $record = XenForo_Model::create('Model_Name')->getUserCodeByUserId($userId);
            if (isset($record['confirmation_key']) && !empty($record['confirmation_key'])) {
                // We need a password change
                throw $controller->responseException($controller->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS,
                    XenForo_Link::buildPublicLink('route-name'),
                    new XenForo_Phrase('message')));
            }
        }

If condition meet it throw the redirection issue.

Is there anyone please help to get this out and put me in right direction.


Thanks
 
Back
Top Bottom