Override next_url so all users redirect to index page after login

19 views
Skip to first unread message

andyweb...@gmail.com

unread,
Nov 22, 2025, 2:03:48 AM (13 days ago) Nov 22
to py4web
Most of my users never log out.  Their sessions expire overnight, so they have to login each morning. After login, the next_url parameter redirects them to their previous page.

What is the recommended way to override this default behaviour? I want to redirect all users to the index page every day, after they login.

Any suggestions much appreciated!

Paul Ellis

unread,
Nov 22, 2025, 3:14:30 AM (13 days ago) Nov 22
to py4web
You could try adding something like this to your auth definition. There's two parameters passed to the callback function. I can't remember what the first one is. It might be the form? I use it to add extra info to the auth.session object but you might be able to call a redirect.
auth.on_accept['login'] = after_login_callback
def after_login_callback(_, user_row):
    # Fetch the reseller_id from the auth_user record
    if settings.DEBUG == True: print(user_row)

    reseller_id = user_row['reseller_id']
    # Add reseller_id to the auth.user object
    auth.session['reseller_id'] = reseller_id

Andrew Webster

unread,
Nov 22, 2025, 7:07:43 AM (12 days ago) Nov 22
to py4web
Thanks for the pointer Eddie - I will look into this.
Reply all
Reply to author
Forward
0 new messages