{"action":"opened","issue":{"url":"https://api.github.com/repos/silexlabs/Silex/issues/465","repository_url":"https://api.github.com/repos/silexlabs/Silex","labels_url":"https://api.github.com/repos/silexlabs/Silex/issues/465/labels{/name}","comments_url":"https://api.github.com/repos/silexlabs/Silex/issues/465/comments","events_url":"https://api.github.com/repos/silexlabs/Silex/issues/465/events","html_url":"https://github.com/silexlabs/Silex/issues/465","id":172302816,"number":465,"title":" before middleware generates an infinite redirect loop","user":{"login":"DaveSanchez","id":7015891,"avatar_url":"https://avatars.githubusercontent.com/u/7015891?v=3","gravatar_id":"","url":"https://api.github.com/users/DaveSanchez","html_url":"https://github.com/DaveSanchez","followers_url":"https://api.github.com/users/DaveSanchez/followers","following_url":"https://api.github.com/users/DaveSanchez/following{/other_user}","gists_url":"https://api.github.com/users/DaveSanchez/gists{/gist_id}","starred_url":"https://api.github.com/users/DaveSanchez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaveSanchez/subscriptions","organizations_url":"https://api.github.com/users/DaveSanchez/orgs","repos_url":"https://api.github.com/users/DaveSanchez/repos","events_url":"https://api.github.com/users/DaveSanchez/events{/privacy}","received_events_url":"https://api.github.com/users/DaveSanchez/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-21T03:42:22Z","updated_at":"2016-08-21T03:42:22Z","closed_at":null,"body":"\r\n\r\nHi, I'm new with silex and I'm trying to build a simple login and register system. I wrote a before middleware that checks if a user session variable is set, if it's true it means that user is already logged in, otherwise is not and it must be redirecting to the home page where only a login form is visible.\r\n\r\n`<?php\r\n\r\n$app->before(function () use($app) {\r\n\r\n// Checa si ya existe una sesion 'user' existente en variable\r\n$userisloggedin = is_null($app['session']->get('user')) ? false : true;\r\n\r\n//Da valor bool a la variable auth de Silex para saber que mostrar si hay o no una session\r\n$app['twig']->addGlobal('auth',$userisloggedin);\r\n\r\nif(!$userisloggedin) {\r\n    return $app->redirect($app[\"url_generator\"]->generate(\"home\"));\r\n}\r\n\r\n});`\r\n\r\nThe problem is, when redirects to the home page, the user session is not exists yet, so it's redirecting over and over again to the home page and generates an error which is The page isn't redirecting properly\r\n\r\nso I would like to know if it is possible to omit the home route for this middleware or what would be a solution for this. Sorry if my english is not good. Thank you!\r\n"}}
{"actor":{"display_login":"DaveSanchez"}}