"""Custom JWT token — embeds session_id for concurrent session management."""

from rest_framework_simplejwt.tokens import RefreshToken


class SessionRefreshToken(RefreshToken):
    """RefreshToken subclass that writes session_id into JWT claims."""

    @classmethod
    def for_user_session(cls, user, session_id):
        token = cls.for_user(user)
        token['session_id'] = str(session_id)
        return token
