<commit_before>from django.contrib.auth import authenticate, login, logout

from rest_framework.response import Response
from rest_framework import viewsets, status


class AuthViewSet(viewsets.ViewSet):
    permission_classes = ()

    def list(self, request):
        if request.user.is_authenticated():
            return Response(status=200)
        else:
            return Response(status=401)

    def create(self, request):
        username = request.DATA['username']
        password = request.DATA['password']

        user = authenticate(username=username, password=password)

        if user is not None:
            if user.is_active:
                login(request, user)
                return Response(status=200)
            else:
                return Response(status=401)
        else:
            return Response(status=401)

    def destroy(self, request, pk=None):
        logout(request)
        return Response(status=200)
<commit_msg>GET /auth: new response format<commit_after>from django.contrib.auth import authenticate, login, logout

from rest_framework.response import Response
from rest_framework import viewsets, status


class AuthViewSet(viewsets.ViewSet):
    permission_classes = ()

    def list(self, request):
        if request.user.is_authenticated():
            return Response(data={'user': {'username': request.user.username}}, status=200)
        else:
            return Response(status=401)

    def create(self, request):
        username = request.DATA['username']
        password = request.DATA['password']

        user = authenticate(username=username, password=password)

        if user is not None:
            if user.is_active:
                login(request, user)
                return Response(status=200)
            else:
                return Response(status=401)
        else:
            return Response(status=401)

    def destroy(self, request, pk=None):
        logout(request)
        return Response(status=200)

{'fraction_non_alphanumeric': 0.09058882737795672, 'fraction_numerical': 0.018117765475591345, 'mean_word_length': 2.4816112084063047, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3719143', 'n_tokens_mistral': 548, 'n_tokens_neox': 500, 'n_words': 131}