I cannot reproduce any of your problems. The redirection works fine for me
in 2.7.2. Something else may be affecting your redirection.
There are some error in your code, although, not cause of your problem:
def register_user():
register = auth.register()
if register.process().accepted: #### WRONG
redirect(URL('welcome'))
because you cannot process() and registration form. it is already processed
Should be:
def register_user():
register = auth.register(next=URL('welcome'))
return dict(register = register)
You display the login form in the index page even if the user is already
logged in.
The button to the register page will redirect to the profile page if the
user is already logged in.
On Thursday, 27 June 2013 08:36:27 UTC-5, [email protected] wrote:
>
>
>
> hello together,
>
> my problem is , i want a simply redirect after a user is logged in.
>
> i am using the auth setup from web2py:
>
>
>
> my db.py:
>
> auth = Auth(db)
> auth.define_tables(username=True)
> auth.settings.login_next = URL('welcome') this has no effect, after a
> user login the index page is still shown
>
>
> the controller:
>
> def index():this is my index page, the first page show to the user, where
> the user can login or register
>
> user_auth = auth.login()
> user_auth.add_button('register me', URL('register_user'))
>
>
> return dict(user_auth = user_auth)
>
> def invalid_user():
> return dict()
>
> def welcome():after login was succsesfull the user should be directed to
> welcome
> search = FORM('Search for:', INPUT(_name='name'),
> INPUT(_type='submit', _value = 'go!!!!'))
>
> return dict(search = search)
>
>
> def register_user():
> register = auth.register()
>
> if register.process().accepted:
> redirect(URL('welcome'))
>
>
> return dict(register = register)
>
>
> the view: this is the first site that the user is shown
> <h1>Login:</h1>
> <br>
> {{=user_auth}} it simply show the form from index() its auth.login()
>
>
> the flow is that the user first see the index page with the login,
> now user is able to login or create a account,
> if the user log in , with an allready created account she schould be
> redircted to the welcome page.
>
>
>
> kind regards
>
> Bartek
>
>
>
>
>
>
>
--
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 the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.