diff --git a/ereuse_devicehub/resources/device/templates/devices/layout.html b/ereuse_devicehub/resources/device/templates/devices/layout.html
index 713fdaf4..ed89a16a 100644
--- a/ereuse_devicehub/resources/device/templates/devices/layout.html
+++ b/ereuse_devicehub/resources/device/templates/devices/layout.html
@@ -53,7 +53,7 @@
{% else %}
- Logout
+ Logout
{% endif %}
diff --git a/ereuse_devicehub/views.py b/ereuse_devicehub/views.py
index 91676032..eaa2c4f1 100644
--- a/ereuse_devicehub/views.py
+++ b/ereuse_devicehub/views.py
@@ -66,8 +66,9 @@ class LogoutView(View):
def dispatch_request(self):
session_vars = ['token_dlt', 'rols']
[session.pop(i, '') for i in session_vars]
+ next_url = flask.request.args.get('next')
logout_user()
- return flask.redirect(flask.url_for('core.login'))
+ return flask.redirect(next_url or flask.url_for('core.login'))
class GenericMixin(View):