I am trying to create a reset password page and tried to open the reset page upon clicking the “Forgot password?” link but the issue is that it keeps going on loop until the browser will display “ERR_TOO_MANY_REDIRECTS” or mypage.local redirected you too many times.
What I did is add some small changes to the AuthMiddleware.php so it would redirect to ‘reset.page’ when “Forgot password?” is clicked.
public function __invoke($request, $response, $next)
{
if (!$this->container->auth->checkSession()) {
$this->container->flash->addMessage('error', 'Your session has expired.');
return $response->withRedirect($this->container->router->pathFor('login.page'));
}
$getPath = $request->getUri()->getPath();
if (!$this->container->auth->check() && strpos($getPath,'reset')) {
return $response->withRedirect($this->container->router->pathFor('reset.page', [], [
'callback' => $request->getUri()->getPath()
]));
}
if (!$this->container->auth->check() ) {
$this->container->flash->addMessage('error', 'Please login first');
return $response->withRedirect($this->container->router->pathFor('login.page', [], [
'callback' => $request->getUri()->getPath()
]));
}
$response = $next($request, $response);
return $response;
}