I'm not sure if this is the officially correct way to do this, but I
implemented this functionality by making a change to layout.html:

I replaced these lines:
-       {{=A(T('login'),_href=URL(r=request,c='default',f='user/login'))}} |
-       {{=A(T('register'),_href=URL(r=request,c='default',f='user/
register'))}} ]

With these lines:
+       {{=A(T('login'),_href=URL(r=request,c='default',f='user/login?_next=
%s' % request.url))}} |
+       {{=A(T('register'),_href=URL(r=request,c='default',f='user/register?
_next=%s' % request.url))}} ]

This works because before web2py checks auth.settings.login_next it
checks the POST and GET variables to see if the variable '_next' is
included.  I have a very simple site right now, so I don't know how
well this will work for you.  For example, it does not maintain the
query string from the current URL (ie, ?var1=value1&var2=value2,
etc).  You can probably tweak this to provide that functionality,
though.

-Mike

On Sep 17, 1:27 am, b vivek <[email protected]> wrote:
> Hi!
> This might seem silly, but here it goes.I was making a sort of blogging app.
> where ass of now after login/logout a person is redirected to the home page,
> using this:-
> auth.settings.login_next=URL('homepage')
> auth.settings.logout_next=URL('homepage')
> Instead of this, I want him to be redirected to the page from which he
> actually came to the login page. Let me give an example here. Suppose the
> person was reading the blogs and he is on a page "http://../jingle/"; and he
> decides to login, clicks the login button and goes to the login page, after
> login , he should be redirected back to the page"http://../jingle/"; instead
> of the home page. Can someone help.
>
> Thanks
> Vivek

Reply via email to