diff --git a/plinth/modules/sso/views.py b/plinth/modules/sso/views.py index 749cbce19..eea5cd02d 100644 --- a/plinth/modules/sso/views.py +++ b/plinth/modules/sso/views.py @@ -25,7 +25,6 @@ import urllib from django.contrib.auth import REDIRECT_FIELD_NAME from django.contrib.auth.views import LoginView, LogoutView from django.http import HttpResponseRedirect -from django.utils import translation from axes.decorators import axes_form_invalid from axes.utils import reset @@ -66,7 +65,6 @@ class SSOLoginView(LoginView): def dispatch(self, request, *args, **kwargs): response = super(SSOLoginView, self).dispatch(request, *args, **kwargs) if request.user.is_authenticated: - request.session[translation.LANGUAGE_SESSION_KEY] = request.user.userprofile.preferred_language return set_ticket_cookie(request.user, response) else: return response diff --git a/plinth/translation.py b/plinth/translation.py index 357a6b7b0..df75dcd18 100644 --- a/plinth/translation.py +++ b/plinth/translation.py @@ -71,3 +71,9 @@ def set_language(request, response, language_code): path=settings.LANGUAGE_COOKIE_PATH, domain=settings.LANGUAGE_COOKIE_DOMAIN, ) + + +@receiver(user_logged_in) +def _on_user_logged_in(sender, request, user, **kwargs): + """When the user logs in, set the current language.""" + set_language(request, None, user.userprofile.language)