diff --git a/flat/views.py b/flat/views.py index 08a7aa1..bd8824f 100644 --- a/flat/views.py +++ b/flat/views.py @@ -256,6 +256,7 @@ def pub_query(request,configuration, docid): def login(request): oidc = settings.OIDC if hasattr(settings, 'OIDC') else False + loggedin = request.user.is_authenticated if isinstance(request.user.is_authenticated, bool) else request.user.is_authenticated() if 'username' in request.POST and 'password' in request.POST: username = request.POST['username'] password = request.POST['password'] @@ -274,12 +275,12 @@ def login(request): return redirect(base_prefix + "/") else: # Return a 'disabled account' error message - return render(request, 'login.html', {'error': "This account is disabled","defaultconfiguration":settings.DEFAULTCONFIGURATION, "configurations":settings.CONFIGURATIONS , 'version': settings.VERSION, "allowregistration": hasattr(settings, 'ALLOWREGISTRATION') and settings.ALLOWREGISTRATION,'base_prefix': settings.BASE_PREFIX if hasattr(settings,'BASE_PREFIX') else "", 'oidc': oidc, 'username': request.user.email if oidc else request.user.username, 'loggedin': request.user.is_authenticated if isinstance(request.user.is_authenticated, bool) else request.user.is_authenticated() } ) + return render(request, 'login.html', {'error': "This account is disabled","defaultconfiguration":settings.DEFAULTCONFIGURATION, "configurations":settings.CONFIGURATIONS , 'version': settings.VERSION, "allowregistration": hasattr(settings, 'ALLOWREGISTRATION') and settings.ALLOWREGISTRATION,'base_prefix': settings.BASE_PREFIX if hasattr(settings,'BASE_PREFIX') else "", 'oidc': oidc, 'username': 'anonymous' if not loggedin else request.user.email if oidc else request.user.username, 'loggedin': loggedin } ) else: # Return an 'invalid login' error message. - return render(request, 'login.html', {'error': "Invalid username or password","defaultconfiguration":settings.DEFAULTCONFIGURATION, "configurations":settings.CONFIGURATIONS, 'version': settings.VERSION, "allowregistration": hasattr(settings, 'ALLOWREGISTRATION') and settings.ALLOWREGISTRATION,'base_prefix': settings.BASE_PREFIX if hasattr(settings,'BASE_PREFIX') else "", 'oidc': oidc , 'username': request.user.email if oidc else request.user.username, 'loggedin': request.user.is_authenticated if isinstance(request.user.is_authenticated, bool) else request.user.is_authenticated()} ) + return render(request, 'login.html', {'error': "Invalid username or password","defaultconfiguration":settings.DEFAULTCONFIGURATION, "configurations":settings.CONFIGURATIONS, 'version': settings.VERSION, "allowregistration": hasattr(settings, 'ALLOWREGISTRATION') and settings.ALLOWREGISTRATION,'base_prefix': settings.BASE_PREFIX if hasattr(settings,'BASE_PREFIX') else "", 'oidc': oidc, 'username': 'anonymous' if not loggedin else request.user.email if oidc else request.user.username, 'loggedin': loggedin} ) else: - return render(request, 'login.html',{"defaultconfiguration":settings.DEFAULTCONFIGURATION, "configurations":settings.CONFIGURATIONS, "version": settings.VERSION, "allowregistration": hasattr(settings, 'ALLOWREGISTRATION') and settings.ALLOWREGISTRATION,'base_prefix': settings.BASE_PREFIX if hasattr(settings,'BASE_PREFIX') else "", 'oidc': oidc, 'username': request.user.email if oidc else request.user.username, 'loggedin': request.user.is_authenticated if isinstance(request.user.is_authenticated, bool) else request.user.is_authenticated() }) + return render(request, 'login.html',{"defaultconfiguration":settings.DEFAULTCONFIGURATION, "configurations":settings.CONFIGURATIONS, "version": settings.VERSION, "allowregistration": hasattr(settings, 'ALLOWREGISTRATION') and settings.ALLOWREGISTRATION,'base_prefix': settings.BASE_PREFIX if hasattr(settings,'BASE_PREFIX') else "", 'oidc': oidc, 'username': 'anonymous' if not loggedin else request.user.email if oidc else request.user.username, 'loggedin': loggedin }) def logout(request):