Skip to content
Snippets Groups Projects

Resolve "LDAP connector"

Merged Piotr Gawron requested to merge 380-ldap-connector into master
1 unresolved thread
1 file
+ 11
10
Compare changes
  • Side-by-side
  • Inline
@@ -2,19 +2,20 @@ import logging
from django.contrib.auth.backends import ModelBackend
from web.models import Worker
logger = logging.getLogger(__name__)
class CustomModelBackend(ModelBackend):
def authenticate(self, request, username=None, password=None, **kwargs):
logger.debug("Trying LOCAL auth with: " + username)
count = Worker.objects.filter(user__username=username, user__is_active=True, ldap_user=False).count()
if count == 1:
return super().authenticate(request, username, password, **kwargs)
else:
return None
# FIXME: If we want to prevent login of users without Worker this should work
# logger.debug("Trying LOCAL auth with: " + username)
#
# count = Worker.objects.filter(user__username=username, user__is_active=True, ldap_user=False).count()
#
# if count == 1:
# return super().authenticate(request, username, password, **kwargs)
# else:
# return None
return super().authenticate(request, username, password, **kwargs)
Loading