php - How do I make an internal redirect in Silex / Symfony? -
i have users getting auto-generated when login via social media. don't email want make when land on /whatever/page/after/login
see screen that's "just enter email continue on!"
i took @ http://silex.sensiolabs.org/doc/cookbook/sub_requests.html , i'm either misreading or thinking i'd need within silex\controllerproviderinterface
. want behavior request. meanwhile if make providers extend one, i'm not sure of right way cut out of parent's connect
without botching everything.
i tried re-initializing similar answer here unable overwrite pathinfo in symfony 2 request.
here code i'm working with:
$app ->before(function (request $request) use ($app) { $token = $app['security']->gettoken(); $app['user'] = null; if ($token && !$app['security.trust_resolver']->isanonymous($token)) { $app['user'] = $token->getuser(); if (!$app['user']->isverified()) { $request->server->set('request_uri', '/signup'); $request->initialize($request->query->all(), $request->request->all(), $request->attributes->all(), $request->cookies->all(), $request->files->all(), $request->server->all(), $request->getcontent()); } } });
i believe want create new request
object correct values , tell app handle it.
if don't care preserving request params original request can strip lot of stuff out.
$app ->before(function (request $request) use ($app) { $token = $app['security']->gettoken(); $app['user'] = null; if ($token && !$app['security.trust_resolver']->isanonymous($token)) { $app['user'] = $token->getuser(); if (!$app['user']->isverified()) { $subrequest = request::create('/signup', 'get', $request->attributes->all(), $request->cookies->all(), $request->files->all(), $request->server->all(), $request->getcontent()); $subrequest->request = $request->request; $subrequest->query = $request->query; return $app->handle($subrequest, httpkernelinterface::sub_request); } } });
Comments
Post a Comment