feat: add JWT auth foundation - /api/v1/ with admin login, refresh, me, health endpoints
- Add djangorestframework-simplejwt==5.3.1 to requirements-docker.txt - Configure REST_FRAMEWORK with JWTAuthentication and SIMPLE_JWT settings - Create admin_api Django app with AdminLoginView, MeView, HealthView - Wire /api/v1/ routes without touching existing /api/ mobile endpoints - Resolve pre-existing events migration conflict (0010_merge) - Superuser admin created for initial authentication Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
18
admin_api/serializers.py
Normal file
18
admin_api/serializers.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from rest_framework import serializers
|
||||
from django.contrib.auth import get_user_model
|
||||
User = get_user_model()
|
||||
|
||||
class UserSerializer(serializers.ModelSerializer):
|
||||
name = serializers.SerializerMethodField()
|
||||
role = serializers.SerializerMethodField()
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ['id', 'email', 'username', 'name', 'role']
|
||||
def get_name(self, obj):
|
||||
return f"{obj.first_name} {obj.last_name}".strip() or obj.username
|
||||
def get_role(self, obj):
|
||||
if obj.is_superuser:
|
||||
return 'superadmin'
|
||||
if obj.is_staff:
|
||||
return 'admin'
|
||||
return getattr(obj, 'role', 'user')
|
||||
Reference in New Issue
Block a user