Commit f8b50cd4 authored by Michael Fladischer's avatar Michael Fladischer

New upstream version 1.3.0

parent 54f4d660
Metadata-Version: 1.1
Name: djoser
Version: 1.2.1
Version: 1.3.0
Summary: REST version of Django authentication system.
Home-page: https://github.com/sunscrapers/djoser
Author: SUNSCRAPERS
......@@ -43,9 +43,10 @@ Description: ======
To be able to run **djoser** you have to meet following requirements:
- Python (2.7, 3.4, 3.5, 3.6)
- Django (1.11, 2.0)
- Django (1.11, 2.0, 2.1)
- Django REST Framework (3.7, 3.8)
Bear in mind that for Django-2.x you will need at least Python 3.5
Installation
============
......
......@@ -35,9 +35,10 @@ Requirements
To be able to run **djoser** you have to meet following requirements:
- Python (2.7, 3.4, 3.5, 3.6)
- Django (1.11, 2.0)
- Django (1.11, 2.0, 2.1)
- Django REST Framework (3.7, 3.8)
Bear in mind that for Django-2.x you will need at least Python 3.5
Installation
============
......
Metadata-Version: 1.1
Name: djoser
Version: 1.2.1
Version: 1.3.0
Summary: REST version of Django authentication system.
Home-page: https://github.com/sunscrapers/djoser
Author: SUNSCRAPERS
......@@ -43,9 +43,10 @@ Description: ======
To be able to run **djoser** you have to meet following requirements:
- Python (2.7, 3.4, 3.5, 3.6)
- Django (1.11, 2.0)
- Django (1.11, 2.0, 2.1)
- Django REST Framework (3.7, 3.8)
Bear in mind that for Django-2.x you will need at least Python 3.5
Installation
============
......
__version__ = "1.2.0"
__version__ = "1.3.0"
......@@ -55,6 +55,8 @@ default_settings = {
'djoser.serializers.UserDeleteSerializer',
'user':
'djoser.serializers.UserSerializer',
'current_user':
'djoser.serializers.CurrentUserSerializer',
'token':
'djoser.serializers.TokenSerializer',
'token_create':
......
import warnings
from django.contrib.auth import authenticate, get_user_model
from django.contrib.auth.password_validation import validate_password
from django.core import exceptions as django_exceptions
......@@ -31,6 +33,23 @@ class UserSerializer(serializers.ModelSerializer):
return super(UserSerializer, self).update(instance, validated_data)
class CurrentUserSerializer(settings.SERIALIZERS.user):
def __init__(self, *args, **kwargs):
# Warn user about serializer split
warnings.simplefilter('default')
warnings.warn(
(
'Current user endpoints now use their own serializer setting. '
'For more information, see: '
'https://djoser.readthedocs.io/en/latest/settings.html#serializers' # noqa
),
DeprecationWarning,
)
# Perform regular init actions
super(CurrentUserSerializer, self).__init__(*args, **kwargs)
class UserCreateSerializer(serializers.ModelSerializer):
password = serializers.CharField(
style={'input_type': 'password'},
......
from django.contrib.auth import get_user_model
from django.contrib.auth.tokens import default_token_generator
from django.urls.exceptions import NoReverseMatch
from django.utils.timezone import now
from rest_framework import generics, permissions, status, views, viewsets
from rest_framework.decorators import list_route
from rest_framework.response import Response
......@@ -194,6 +195,8 @@ class PasswordResetConfirmView(utils.ActionViewMixin, generics.GenericAPIView):
def _action(self, serializer):
serializer.user.set_password(serializer.data['new_password'])
if hasattr(serializer.user, 'last_login'):
serializer.user.last_login = now()
serializer.user.save()
return Response(status=status.HTTP_204_NO_CONTENT)
......@@ -283,17 +286,28 @@ class UserViewSet(UserCreateView, viewsets.ModelViewSet):
return super(UserViewSet, self).get_permissions()
def get_serializer_class(self):
if self.action == 'me':
# Use the current user serializer on 'me' endpoints
self.serializer_class = settings.SERIALIZERS.current_user
if self.action == 'create':
return settings.SERIALIZERS.user_create
elif self.action == 'remove' or (
self.action == 'me' and self.request.method == 'DELETE'):
self.action == 'me' and self.request and
self.request.method == 'DELETE'
):
return settings.SERIALIZERS.user_delete
elif self.action == 'confirm':
return settings.SERIALIZERS.activation
elif self.action == 'change_username':
if settings.SET_USERNAME_RETYPE:
return settings.SERIALIZERS.set_username_retype
return settings.SERIALIZERS.set_username
return self.serializer_class
def get_instance(self):
......
......@@ -4,6 +4,7 @@ djangorestframework-jwt==1.11.0
djet==0.2.1
social-auth-app-django==2.1.0
coverage==4.4.1
coreapi==2.3.3
pytest==3.6.2
pytest-cov==2.5.1
......
......@@ -17,7 +17,7 @@ def get_packages(package):
setup(
name='djoser',
version='1.2.1',
version='1.3.0',
packages=get_packages('djoser'),
license='MIT',
author='SUNSCRAPERS',
......
Markdown is supported
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