Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Feb 19, 2021
1 parent 8add082 commit 4487bef
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions flat/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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):
Expand Down

0 comments on commit 4487bef

Please sign in to comment.