Use $this->getUser()->setAttribute('referer', 'URL to come back to');
sfGuard upon successful login should try to take you there. On Sat, May 16, 2009 at 4:53 PM, nick <lal...@teamlalala.com> wrote: > > Clearly, I'm going about this all wrong. If anyone else out there who > has done this wants to chime in, I'd be grateful. > > Out of desperation, I tried the straightforward approach, which I know > is a big hack: > > $arrayOfUrlParts = explode('/', $request->getParameter('redirect')); > $model = $arrayOfUrlParts[0]; > $action = $arrayOfUrlParts[1]; > $queryString = ''; > for ($i=2; $i < count($arrayOfUrlParts); $i++) > { > if ($i % 2 == 0 ) $queryString .= $arrayOfUrlParts[$i] . '='; > if ($i % 2 != 0 ) $queryString .= $arrayOfUrlParts[$i] . '&'; > } > return $this->redirect($model.'/'.$action.'?'.$queryString); > > If I simply echo this last bit to the screen, I can see that I'm > getting exactly what I need as an URL: > > frontend_dev.php/sfZed/zed/model/inventory/id/5 > > But I again get an infinite loop of redirection: > > "Redirect Loop > Firefox has detected that the server is redirecting the request for > this address in a way that will never complete." > > So clearly, this adjustment is suppose to be made somewhere else in > the code. I'm not suppose to be working in sfGuardAuth - executeSignin > (). But where else do I make this adjustment? > > > > > > > > > > > > > On May 15, 11:16 pm, nick <lal...@teamlalala.com> wrote: >> Interesting. I feel like I'm getting closer. Instead of getUri() I >> switched to using getPathInfo() in the form: >> >> <form action="<?php echo url_for('@sf_guard_signin') ?>" >> method="post"> >> <table> >> <?php echo $form ?> >> </table> >> <input type="submit" value="sign in" /> >> <input type="hidden" name="redirect" value="<?php echo substr >> ($sf_request->getPathInfo(), 1) ?>" /> >> </form> >> >> I had to use substr() to remove the first "/" forward slash, otherwise >> the address was treated as absolute from the document root. I then >> changed actions.class.php like this: >> >> $this->finalRedirectInForm = $request->getParameter('redirect'); >> return $this->redirect($this->finalRedirectInForm); >> >> This allowed me to escape the problem that I'd been having before - >> the problem of falling into an infinite loop of redirection. Now if I >> try to go here: >> >> frontend_dev.php/sfStar/starit/model/BailiwickQuestion/id/55 >> >> I'm first redirected to the login screen, and then when that submits, >> I'm redirected here: >> >> frontend_dev.php/sfStar/starit >> >> I've now lost this part of the URL: >> >> model/BailiwickQuestion/id/55 >> >> So I end up with a fatal error: method called on a non-object. >> >> Any thoughts? >> >> I can not believe how hard this is. Seems like this is a fairly common >> thing, that most Symfony developers probably do on most sites. >> >> On May 15, 10:15 pm, nick <lal...@teamlalala.com> wrote: >> >> > On May 15, 2:48 pm, "David Ashwood" <da...@inspiredthinking.co.uk> >> > wrote: >> >> > > Aye - so looking at the code you need to pass the referring URL to the >> > > form >> > > from executeSignin. >> > > In the form them append the referrer to the post request with something >> > > like >> > > "&referrer=url". >> > > Then in the isValid codeblock - pull out the param and use it in your >> > > redirect. >> >> > Are you suggesting (at the end of the process) handing the entire >> > urldecoded() url to $this->redirect()? > > > -- Blue Horn Ltd - System Development http://bluehorn.co.nz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---