Commit 80c02e3a authored by Jan Čermák's avatar Jan Čermák

redirect to last url visited after automatic logout - closes #2920

parent 95c8d41f
......@@ -29,6 +29,7 @@ bottle.SimpleTemplate.defaults["request"] = bottle.request
bottle.SimpleTemplate.defaults["url"] = lambda name, **kwargs: reverse(name, **kwargs)
bottle.SimpleTemplate.defaults["static"] = lambda filename, *args: reverse("static", filename=filename) % args
def login_redirect(step_num):
NUM_WIZZARD_STEPS = 7
if step_num >= NUM_WIZZARD_STEPS:
......@@ -64,8 +65,10 @@ def login():
if _check_password(bottle.request.POST.get("password")):
session["user_authenticated"] = True
session.save()
bottle.redirect("/")
next = bottle.request.POST.get("next")
if next:
bottle.redirect(next)
bottle.redirect("/")
......
......@@ -6,6 +6,9 @@
<a href="{{ url("logout") }}">{{ _("Log out") }}</a>
%else:
<form action="{{ request.fullpath }}" method="POST">
%if request.GET.get("next"):
<input type="hidden" name="next" value="{{ request.GET['next'] }}">
%end
<label for="field-password">{{ _("Password") }}</label>
<input id="field-password" type="password" name="password" placeholder="{{ _("Password") }}">
<button class="button" type="submit">{{ _("Log in") }}</button>
......
......@@ -19,7 +19,7 @@ def login_required(func=None, redirect_url="/"):
no_auth = bottle.default_app().config.no_auth
if not no_auth and not session.get("user_authenticated", False):
# "raise" bottle redirect
bottle.redirect(redirect_url)
bottle.redirect("%s?next=%s" % (redirect_url, bottle.request.fullpath))
return func(*args, **kwargs)
return wrapper
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment