mirror of
https://github.com/ferdzo/iotDashboard.git
synced 2026-04-05 17:16:26 +00:00
Added auth, environment brief, docker for db_migrations,frontend,backend.
This commit is contained in:
23
iotDashboard/jwt_serializers.py
Normal file
23
iotDashboard/jwt_serializers.py
Normal file
@@ -0,0 +1,23 @@
|
||||
"""
|
||||
Custom JWT serializers for IoT Dashboard.
|
||||
Handles string-based user IDs instead of integer IDs.
|
||||
"""
|
||||
|
||||
from rest_framework_simplejwt.serializers import TokenObtainPairSerializer
|
||||
from rest_framework_simplejwt.tokens import RefreshToken
|
||||
|
||||
|
||||
class CustomTokenObtainPairSerializer(TokenObtainPairSerializer):
|
||||
"""
|
||||
Custom token serializer that handles string user IDs.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def get_token(cls, user):
|
||||
token = RefreshToken.for_user(user)
|
||||
|
||||
# Add custom claims
|
||||
token['username'] = user.username
|
||||
token['email'] = user.email
|
||||
|
||||
return token
|
||||
Reference in New Issue
Block a user