Mercurial > kallithea
changeset 437:930f8182a884
Added redirection to page that request came from, after login in
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 29 Aug 2010 00:11:28 +0200 |
parents | 28f19fa562df |
children | 0d4fceb91c9c |
files | pylons_app/controllers/login.py pylons_app/lib/auth.py pylons_app/templates/login.html |
diffstat | 3 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/pylons_app/controllers/login.py Sat Aug 28 14:53:32 2010 +0200 +++ b/pylons_app/controllers/login.py Sun Aug 29 00:11:28 2010 +0200 @@ -42,6 +42,8 @@ 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 @@ 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(
--- a/pylons_app/lib/auth.py Sat Aug 28 14:53:32 2010 +0200 +++ b/pylons_app/lib/auth.py Sun Aug 29 00:11:28 2010 +0200 @@ -228,8 +228,12 @@ 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"""
--- a/pylons_app/templates/login.html Sat Aug 28 14:53:32 2010 +0200 +++ b/pylons_app/templates/login.html Sun Aug 29 00:11:28 2010 +0200 @@ -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 -->