forked from ungleich-public/dynamicweb
fix hosting tests
This commit is contained in:
parent
8caca66b66
commit
4bcb3f2e04
5 changed files with 159 additions and 260 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
import sys
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.backends import ModelBackend
|
||||
|
|
@ -7,7 +8,6 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class MyLDAPBackend(ModelBackend):
|
||||
|
||||
def authenticate(self, request, username=None, password=None, **kwargs):
|
||||
user = super().authenticate(
|
||||
request=request,
|
||||
|
|
@ -16,7 +16,12 @@ class MyLDAPBackend(ModelBackend):
|
|||
**kwargs
|
||||
)
|
||||
|
||||
if user and not settings.DEBUG:
|
||||
is_testing = (
|
||||
"test" in sys.argv
|
||||
or "pytest" in sys.modules
|
||||
)
|
||||
|
||||
if user and not settings.DEBUG and not is_testing:
|
||||
user.create_ldap_account(password)
|
||||
|
||||
return user
|
||||
Loading…
Add table
Add a link
Reference in a new issue