mirror of
https://github.com/Tivix/django-rest-auth.git
synced 2024-12-03 06:13:43 +03:00
Merge pull request #82 from brunomichetti/fix/make-verify-email-browsable
Make verify email browsable
This commit is contained in:
commit
0fdb2f9bd8
|
@ -19,7 +19,7 @@ from django.utils.decorators import method_decorator
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.views.decorators.debug import sensitive_post_parameters
|
from django.views.decorators.debug import sensitive_post_parameters
|
||||||
from rest_framework import status
|
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.generics import CreateAPIView, GenericAPIView, ListAPIView
|
||||||
from rest_framework.permissions import AllowAny, IsAuthenticated
|
from rest_framework.permissions import AllowAny, IsAuthenticated
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
@ -87,6 +87,9 @@ class VerifyEmailView(APIView, ConfirmEmailView):
|
||||||
def get_serializer(self, *args, **kwargs):
|
def get_serializer(self, *args, **kwargs):
|
||||||
return VerifyEmailSerializer(*args, **kwargs)
|
return VerifyEmailSerializer(*args, **kwargs)
|
||||||
|
|
||||||
|
def get(self, *args, **kwargs):
|
||||||
|
raise MethodNotAllowed('GET')
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
serializer = self.get_serializer(data=request.data)
|
serializer = self.get_serializer(data=request.data)
|
||||||
serializer.is_valid(raise_exception=True)
|
serializer.is_valid(raise_exception=True)
|
||||||
|
|
|
@ -466,6 +466,13 @@ class APIBasicTests(TestsMixin, TestCase):
|
||||||
new_user = get_user_model().objects.latest('id')
|
new_user = get_user_model().objects.latest('id')
|
||||||
self.assertEqual(new_user.username, self.REGISTRATION_DATA['username'])
|
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
|
# email is not verified yet
|
||||||
payload = {
|
payload = {
|
||||||
"username": self.USERNAME,
|
"username": self.USERNAME,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user