Changeset - 930f8182a884
[Not reviewed]
default
0 3 0
Marcin Kuzminski - 15 years ago 2010-08-29 00:11:28
marcin@python-works.com
Added redirection to page that request came from, after login in
3 files changed with 13 insertions and 4 deletions:
0 comments (0 inline, 0 general)
pylons_app/controllers/login.py
Show inline comments
 
@@ -42,6 +42,8 @@ class LoginController(BaseController):
 

	
 
    def index(self):
 
        #redirect if already logged in
 
        c.came_from = request.GET.get('came_from',None)
 
        
 
        if c.hg_app_user.is_authenticated:
 
            return redirect(url('hg_home'))
 
        
 
@@ -50,7 +52,10 @@ class LoginController(BaseController):
 
            login_form = LoginForm()
 
            try:
 
                c.form_result = login_form.to_python(dict(request.POST))
 
                return redirect(url('hg_home'))
 
                if c.came_from:
 
                    return redirect(c.came_from)
 
                else:
 
                    return redirect(url('hg_home'))
 
                               
 
            except formencode.Invalid as errors:
 
                return htmlfill.render(
pylons_app/lib/auth.py
Show inline comments
 
@@ -228,8 +228,12 @@ class LoginRequired(object):
 
            return func(*fargs, **fkwargs)
 
        else:
 
            log.warn('user %s not authenticated', user.username)
 
            log.debug('redirecting to login page')
 
            return redirect(url('login_home'))
 

	
 
            p = request.environ.get('PATH_INFO')
 
            if request.environ.get('QUERY_STRING'):
 
                p+='?'+request.environ.get('QUERY_STRING')
 
            log.debug('redirecting to login page with %',p)                
 
            return redirect(url('login_home',came_from=p))
 

	
 
class PermsDecorator(object):
 
    """Base class for decorators"""
pylons_app/templates/login.html
Show inline comments
 
@@ -24,7 +24,7 @@
 
                <div class="corner tr"></div>
 
            </div>
 
            <div class="inner">            
 
                ${h.form(h.url.current())}
 
                ${h.form(h.url.current(came_from=c.came_from))}
 
                <div class="form">
 
                    <!-- fields -->
 

	
0 comments (0 inline, 0 general)