. I think I figured it out,

. Once again, it boils down just to a few lines of code :)

- Here is the solution:
  I'm still testing it, but so far so good.

Note:
For the longest time, I had two "r" in request.env.http_referer
which DID NOT WORK. 
Ref: 
https://groups.google.com/forum/?fromgroups=#!topic/web2py/jGZgPYGNzuY
Jonathan Lundell     
It's not your problem, but it's 'http_referer'; it got misspelled somewhere 
back in the mists of Internet time.



#########################################################################
#
# Solution: how to have a user redirected to a page AFTER login
#           and to have Profile Update, redirect to Profile, with flash 
message    
# in this example, the URL('user/profile') will be used.

# app name: AuthRedirect  <- just a NEW application, with no modication
# web2py Version 2.2.1 (2012-10-21 16:57:04) stable

# - - - - -
# in layout view, modify the line:
# <ul id="navbar" class="nav pull-right">{{='auth' in globals() and 
auth.navbar(mode="dropdown") or ''}}</ul>
# to
# <ul id="navbar" class="nav pull-right">{{='auth' in globals() and 
auth.navbar(mode="dropdown",referrer_actions=None) or ''}}</ul>
# this will cause the URL not to display
# 
http://127.0.0.1:8000/AuthRedirect/default/user/login?_next=/AuthRedirect/default/index
 

# but rather
# http://127.0.0.1:8000/AuthRedirect/default/user/

# - - - - -
# two lines of CODE BELOW placed in : 
# /models/db.py - located BELOW the  setting under > ## configure auth 
policy lines

auth.settings.login_next = URL('user/profile')
# When user updates profile, they will be redirected to profile, with flash 
message 
auth.settings.profile_next = URL('user/profile')

#########################################################################



#########################################################################   
 
# This conditional in def user(): in default.py
# Purpose: if is to .flash a message when user updates profile, and stay 
# on profile page
                           
                            
                            
    if '/profile' in request.env.http_referer and request.args(0)=='profile'
: 
            
            response.flash = T("Profile saved.")
            
#########################################################################






-- 



Reply via email to