I edited my question from yesterday: django authenticate() allways returns None, but I think noone will will pay attention because I already marked the question as answered. - a
On django version 2.1 or above, you should pass the request into function authenticate for the customized authentication. For example:
class PasswordlessAuthenticationBackend(object):
def authenticate(self, request, uid):
try:
token = Token.objects.get(uid=uid)
print('got user', file=sys.stderr)
return ListUser.objects.get(email=token.email)
except ListUser.DoesNotExist:
print('new user', file=sys.stderr)
return ListUser.objects.create(email=token.email)
except Token.DoesNotExist:
return None
Finally, don't forget the settings in settings.py: 1. accounts is your app name 2. ListUser is your model name
AUTH_USER_MODEL = 'accounts.ListUser'
AUTHENTICATION_BACKENDS = (
'accounts.authentication.PasswordlessAuthenticationBackend',
)
Now authenticate() works. It was a version-mismatch. Now I remember that I created the initial project at home and on my gentoo-machine there still is the version 1.7.7 installed and on the windows-machine at work 1.8.4., I think it is the different settings-file, stupid mistake from me.
Sorry for the inconvenience