Open neldivad opened 2 months ago
Django Ninja's auth will store the authenticated entity in request.auth
. request.user
is still what authenticated by your Django settings, e.g. user of current session with django.contrib.sessions.middleware.SessionMiddleware
.
Example from doc:
from ninja import NinjaAPI
from ninja.security import django_auth
api = NinjaAPI(csrf=True)
@api.get("/pets", auth=django_auth)
def pets(request):
return f"Authenticated user {request.auth}"
When disabling auth
This decorator is so frustrating to use. Different apps gets authenticated and sometimes it doesn't.
I tried logging out and logging in from admin page. Tried different browser, Tried incognito. This JWT auth is the one that has been giving me a huge issue.