Closed rokdd closed 2 years ago
Found the problem myself and maybe it helps others as well:
AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.ModelBackend','sesame.backends.ModelBackend']
If you'd like to consider contributing a django system check to check for this, I'd be open to reviewing it.
Well I mean some ppl might be not like to use the Django Backend, so then in the check it would like mandatory? Or do I understand this wrong?
The backend is required if you are using sesame?
Sure. But the Django backend, which I was missing in my settings, is only required when you use the native login of Django somewhere.
Oh right, it wasn't clear from your comment that it was the Django backend you were missing, rather than sesame's.
Perhaps the example could be changed from the somewhat cryptic:
AUTHENTICATION_BACKENDS += ["sesame.backends.ModelBackend"]
to a more obvious:
AUTHENTICATION_BACKENDS = [
"django.contrib.auth.backends.ModelBackend",
"sesame.backends.ModelBackend", # add this line
]
@rokdd Do you think you would have avoided this problem?
If that's clearer, then we could similarly do:
MIDDLEWARE += [
...,
"django.contrib.auth.middleware.AuthenticationMiddleware",
"sesame.middleware.AuthenticationMiddleware", # add this line
...,
]
which is easier to visualize than:
The best position for
sesame.middleware.AuthenticationMiddleware
is just afterdjango.contrib.auth.middleware.AuthenticationMiddleware
.
Well my problem was the backend... so I would say the snippet should change like this:
AUTHENTICATION_BACKENDS = [
'sesame.backends.ModelBackend',
'django.contrib.auth.backends.ModelBackend'
]
I want to achieve to log in by django-sesame and django-admin by password. The login is working with password until I add the
sesame.middleware.AuthenticationMiddleware
into settings. Django just says that I have the wrong password, so there is no error. My user model looks like this:I could not find any ticket or issue regarding the django-admin. Do I have not seen something in the settings or what I am doing wrong?