diff --git a/plinth/modules/sso/views.py b/plinth/modules/sso/views.py
index 006072aa9..e9f84d4b0 100644
--- a/plinth/modules/sso/views.py
+++ b/plinth/modules/sso/views.py
@@ -14,6 +14,7 @@ from django.contrib.auth import logout as auth_logout
from django.contrib.auth.views import LoginView
from django.http import HttpResponseRedirect
from django.utils.translation import gettext as _
+from django.views.decorators.http import require_POST
from plinth import translation, utils, web_framework
@@ -92,6 +93,7 @@ class CaptchaLoginView(LoginView):
return set_ticket_cookie(request.user, response)
+@require_POST
def logout(request):
"""Logout an authenticated user, remove SSO cookie and redirect to home."""
auth_logout(request)
diff --git a/plinth/templates/base.html b/plinth/templates/base.html
index 76db24170..e86199692 100644
--- a/plinth/templates/base.html
+++ b/plinth/templates/base.html
@@ -184,10 +184,12 @@
{% endif %}
-
- {% trans "Log out" %}
-
+
@@ -211,12 +213,12 @@
{% endif %}
{% if user.is_authenticated %}
-
-
-
- {% trans "Log out" %}
-
+
{% endif %}
{% endblock %}
diff --git a/plinth/tests/functional/__init__.py b/plinth/tests/functional/__init__.py
index 35396dd3f..a8e601d46 100644
--- a/plinth/tests/functional/__init__.py
+++ b/plinth/tests/functional/__init__.py
@@ -277,7 +277,7 @@ def login_with_account(browser, url, username, password=None):
if user_menu.text == username:
return
- visit(browser, '/plinth/accounts/logout/')
+ logout(browser)
login_button = browser.links.find_by_href('/plinth/accounts/login/')
if login_button:
@@ -306,7 +306,14 @@ def login_with_account(browser, url, username, password=None):
def logout(browser):
"""Log out of the FreedomBox interface."""
- visit(browser, '/plinth/accounts/logout/')
+ # Navigate to the home page if logout form is not found
+ if not browser.find_by_css('.form-logout'):
+ visit(browser, '/plinth/')
+
+ # We are not logged in if the home page does not contain logout form
+ if browser.find_by_css('.form-logout'):
+ browser.find_by_id('id_user_menu').click()
+ submit(browser, form_class='form-logout')
#################
diff --git a/static/themes/default/css/main.css b/static/themes/default/css/main.css
index c939d0363..5f6b2a94d 100644
--- a/static/themes/default/css/main.css
+++ b/static/themes/default/css/main.css
@@ -457,6 +457,11 @@ footer {
height: 3.25rem;
}
+.main-header .nav-link,
+.main-header .nav-link:hover {
+ color: white;
+}
+
.main-header .navbar-toggler {
border: 1px solid #ddd;
}