Skip to content
Snippets Groups Projects
Commit 9c8377a5 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

for now allow users without worker to log in

parent bb8e41f6
No related branches found
No related tags found
1 merge request!352Resolve "LDAP connector"
Pipeline #47729 passed
......@@ -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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment