diff --git a/cps/templates/layout.html b/cps/templates/layout.html
index 1bee1c1d..ff1c3687 100644
--- a/cps/templates/layout.html
+++ b/cps/templates/layout.html
@@ -62,13 +62,13 @@
{% if g.current_theme == 1 %}
@@ -91,9 +91,9 @@
{{_('Admin')}}
{% endif %}
{% if g.current_theme == 0 %}
- {{current_user.name}}
+ {{current_user.name}}
{% if not current_user.is_anonymous %}
- {{_('Logout')}}
+ {{_('Logout')}}
{% endif %}
{% endif %}
{% endif %}
diff --git a/cps/web.py b/cps/web.py
index 3e0fce9a..b53fe421 100644
--- a/cps/web.py
+++ b/cps/web.py
@@ -1451,7 +1451,14 @@ def logout():
if feature_support['oauth'] and (config.config_login_type == 2 or config.config_login_type == 3):
logout_oauth_user()
log.debug("User logged out")
- return redirect(url_for('web.login'))
+ if config.config_anonbrowse:
+ location = get_redirect_location(request.args.get('next', None), "web.login")
+ else:
+ location = None
+ if location:
+ return redirect(location)
+ else:
+ return redirect(url_for('web.login'))
# ################################### Users own configuration #########################################################