URL is in Symfony format, e.g.: 'module/action?param=value'

Don't set the following app.yml sfGuard's setttings:

all:
  sf_guard_plugin:
    success_signin_url:      @my_route?param=value # the plugin use
the referer as default

On Sat, May 16, 2009 at 6:46 PM, nick <lal...@teamlalala.com> wrote:
>
>
>
> On May 16, 12:59 am, Sid Bachtiar <sid.bacht...@gmail.com> wrote:
>> Use
>>
>> $this->getUser()->setAttribute('referer', 'URL to come back to');
>>
>> sfGuard upon successful login should try to take you there.
>
>
> Sad to say, that didn't work. My code now looks like this:
>
>
> if ($request->getParameter('redirect'))
> {
>  $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] . '&';
>  }
>  $this->getUser()->setAttribute('referer', $model.'/'.$action.'?'.
> $queryString);
> }
> $signinUrl = sfConfig::get('app_sf_guard_plugin_success_signin_url',
> $user->getReferer('@homepage'));
> return $this->redirect($signinUrl);
>
>
> Just as before, when I log in, I'm sent back to the home page, rather
> than being sent forward to the page that I was trying to go to. But if
> I echo  $model.'/'.$action.'?'.$queryString to the screen I can see
> that I have the right URL. But it is only the right URL the first time
> this code runs through (that is, when I submit the login form).
> Symfony then reloads the signin() method a second time, and at that
> point the page I'm coming from is the login page.
>
> I'm assuming this is a task that a lot of Symfony developers have
> implemented on their own sites. Could someone please post some sample
> code?
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>> 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 Developmenthttp://bluehorn.co.nz
> >
>



-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to