A single redirect is causing two redirects and I can't figure out why. The code is intended to catch any uri containing "logout" and send it to the auth controller which will do the logout process.
Many thanks for any help/advice
Bill
in Routes I have only the following
Code:
if(in_array('logout',explode('/',uri_string()))) {
log_message('error', 'send to auth::loginout');
$routes->post('/(:any)', 'Auth::loginout');
} else {
$routes->get('/(:any)', '\App\Controllers\External\Home::index');
log_message('error', 'authNotRequired "' . uri_string().'" FINISHED');
}
service('auth')->routes($routes);
In the Auth controller I have
Code:
function loginout($par=false){
// ..... the actual logout code will appear here but at the moment there is nothing
log_message('error','auth::logged out now redirect to front');
return redirect()->to('http://192.168.10.161/home');
}
in my log file i see
Code:
route begin -> `front/logout`
send to auth::loginout
auth::logged out now redirect to front <-- the auth controller now calls redirect to home
route begin -> `home` <-- this is where the router sees the uri for home
authNotRequired "home" FINISHED <-- router is now finished with call to home
route begin -> `home` <-- but here the router has another call to home
not logout
authNotRequired "home" FINISHED
so the redirect to home in the Auth controller is called only once but the router sees it twice. The apache log confirms this
Code:
POST /front/logout
GET /home
GET /home
Stupid me. A moments reflection is worth a years experience. The second call to home was caused by the ajax call acting on the response.
Sorry