Commit 4d8487b2 authored by Gijs Hendriksen's avatar Gijs Hendriksen
Browse files

Merge branch 'fix/authtoken' into 'master'

Fix auth token for JSON requests

See merge request !690
parents 0ba2af30 8ea17da0
......@@ -8,7 +8,9 @@ from django.db.models import Q
from django.http import HttpResponse
from django.shortcuts import get_object_or_404, render
from django.utils.translation import gettext as _
from rest_framework.authtoken.models import Token
from rest_framework.authtoken.views import ObtainAuthToken
from rest_framework.response import Response
from .services import member_achievements
from . import models
......@@ -18,9 +20,15 @@ from .forms import ProfileForm
class ObtainThaliaAuthToken(ObtainAuthToken):
def post(self, request, *args, **kwargs):
request._data = request.POST.copy()
request.POST['username'] = request.POST.get('username').lower()
return super().post(request, *args, **kwargs)
serializer = self.serializer_class(data={
if 'username' in else None,
}, context={'request': request})
user = serializer.validated_data['user']
token, created = Token.objects.get_or_create(user=user)
return Response({'token': token.key})
def filter_users(tab, keywords, year_range):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment