Merge pull request #82 from brunomichetti/fix/make-verify-email-browsable

Make verify email browsable
This commit is contained in:
Michael 2020-06-03 22:55:06 -05:00 committed by GitHub
commit 0fdb2f9bd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -19,7 +19,7 @@ from django.utils.decorators import method_decorator
from django.utils.translation import ugettext_lazy as _
from django.views.decorators.debug import sensitive_post_parameters
from rest_framework import status
from rest_framework.exceptions import NotFound
from rest_framework.exceptions import NotFound, MethodNotAllowed
from rest_framework.generics import CreateAPIView, GenericAPIView, ListAPIView
from rest_framework.permissions import AllowAny, IsAuthenticated
from rest_framework.response import Response
@ -87,6 +87,9 @@ class VerifyEmailView(APIView, ConfirmEmailView):
def get_serializer(self, *args, **kwargs):
return VerifyEmailSerializer(*args, **kwargs)
def get(self, *args, **kwargs):
raise MethodNotAllowed('GET')
def post(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)

View File

@ -466,6 +466,13 @@ class APIBasicTests(TestsMixin, TestCase):
new_user = get_user_model().objects.latest('id')
self.assertEqual(new_user.username, self.REGISTRATION_DATA['username'])
# test browsable endpoint
result = self.get(
self.verify_email_url
)
self.assertEqual(result.status_code, 405)
self.assertEqual(result.json['detail'], 'Method "GET" not allowed.')
# email is not verified yet
payload = {
"username": self.USERNAME,