seller_central_backend/api/authentication.py
2026-08-27 22:10:10 +05:30

17 lines
710 B
Python

from rest_framework.authentication import SessionAuthentication, BaseAuthentication
from django.contrib.auth.models import User
from .models import SupplierProfile
class CsrfExemptSessionAuthentication(SessionAuthentication):
def enforce_csrf(self, request):
return
class DummyAuthentication(BaseAuthentication):
def authenticate(self, request):
user = User.objects.first()
if not user:
user = User.objects.create_user(username='dummy', email='dummy@example.com', password='password')
SupplierProfile.objects.create(user=user)
elif not hasattr(user, 'profile'):
SupplierProfile.objects.create(user=user)
return (user, None)