auth.settings.login_next doesn't redirect after login -

36 views
Skip to first unread message

Vlad

unread,
Jun 6, 2019, 3:54:59 PM6/6/19
to web2py-users
What could be the reason the following code wouldn't redirect to the appropriate URL after login? (still brings to default/index page)

def login_to_url():
   
   auth
.settings.login_next=URL(request.args(0),request.args(1))

   logger
.warning(auth.settings.login_next)
   
   redirect
(URL('default','user',args='login'))

I am missing something basic here, as I checked this parameter in the user function itself:

def user():
    logger
.warning(auth.settings.login_next)
   
return dict(form=auth())

and it's printing out default/index instead of the value I setup. I can't even think about what could possibly reset this variable after I assign it. 

Anthony

unread,
Jun 7, 2019, 12:26:25 PM6/7/19
to web2py-users
On Thursday, June 6, 2019 at 3:54:59 PM UTC-4, Vlad wrote:
What could be the reason the following code wouldn't redirect to the appropriate URL after login? (still brings to default/index page)

def login_to_url():
   
   auth
.settings.login_next=URL(request.args(0),request.args(1))

   logger
.warning(auth.settings.login_next)
   
   redirect
(URL('default','user',args='login'))


Above you set the login_next setting inside the login_to_url() action but then redirect to /default/user. The redirect results in the browser sending a new HTTP request to web2py, and in that new request, your setting is not made. Instead, maybe try:

def login_to_url():
   login_next
= URL(request.args(0), request.args(1))
   redirect
(URL('default','user', args='login', vars=dict(_next=login_next)))

Anthony

Eliezer (Vlad) Tseytkin

unread,
Jun 7, 2019, 12:42:54 PM6/7/19
to web...@googlegroups.com
Oops, got it, repeating this mistake second time.. 
Thank you very much

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/lSvOD-GXM_k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/1457f394-aa1a-458c-935d-e6ddf4888e24%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages