Commit c64e5d92 authored by Michael Fladischer's avatar Michael Fladischer

New upstream version 1.3.2

parent b1e6bcc0
Metadata-Version: 1.1
Name: djoser
Version: 1.3.1
Version: 1.3.2
Summary: REST version of Django authentication system.
Home-page: https://github.com/sunscrapers/djoser
Author: SUNSCRAPERS
......
Metadata-Version: 1.1
Name: djoser
Version: 1.3.1
Version: 1.3.2
Summary: REST version of Django authentication system.
Home-page: https://github.com/sunscrapers/djoser
Author: SUNSCRAPERS
......
......@@ -9,6 +9,7 @@ djoser/compat.py
djoser/conf.py
djoser/constants.py
djoser/email.py
djoser/permissions.py
djoser/serializers.py
djoser/signals.py
djoser/utils.py
......
__version__ = "1.3.1"
__version__ = "1.3.2"
......@@ -7,7 +7,6 @@ from django.utils import six
from django.utils.functional import LazyObject
from django.utils.module_loading import import_string
DJOSER_SETTINGS_NAMESPACE = 'DJOSER'
......@@ -68,6 +67,7 @@ default_settings = {
'password_reset': 'djoser.email.PasswordResetEmail',
}),
'LOGOUT_ON_PASSWORD_CHANGE': False,
'CREATE_SESSION_ON_LOGIN': False,
'USER_EMAIL_FIELD_NAME': 'email',
'SOCIAL_AUTH_TOKEN_STRATEGY': 'djoser.social.token.jwt.TokenStrategy',
'SOCIAL_AUTH_ALLOWED_REDIRECT_URIS': [],
......
from rest_framework import permissions
class CurrentUserOrAdmin(permissions.IsAuthenticated):
def has_object_permission(self, request, view, obj):
user = request.user
return user.is_staff or obj.pk == user.pk
from django.contrib.auth import user_logged_in, user_logged_out
from django.contrib.auth import user_logged_in, user_logged_out, login, logout
from django.utils.encoding import force_bytes, force_text
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode
......@@ -15,11 +15,15 @@ def decode_uid(pk):
def login_user(request, user):
token, _ = settings.TOKEN_MODEL.objects.get_or_create(user=user)
if settings.CREATE_SESSION_ON_LOGIN:
login(request, user)
user_logged_in.send(sender=user.__class__, request=request, user=user)
return token
def logout_user(request):
if settings.CREATE_SESSION_ON_LOGIN:
logout(request)
if settings.TOKEN_MODEL:
settings.TOKEN_MODEL.objects.filter(user=request.user).delete()
user_logged_out.send(
......
......@@ -10,6 +10,7 @@ from rest_framework.reverse import reverse
from djoser import utils, signals
from djoser.compat import get_user_email, get_user_email_field_name
from djoser.conf import settings
from djoser.permissions import CurrentUserOrAdmin
User = get_user_model()
......@@ -256,7 +257,7 @@ class UserView(generics.RetrieveUpdateAPIView):
"""
Use this endpoint to retrieve/update user.
"""
model = User
queryset = User.objects.all()
serializer_class = settings.SERIALIZERS.user
permission_classes = [permissions.IsAuthenticated]
......@@ -275,7 +276,7 @@ class UserView(generics.RetrieveUpdateAPIView):
class UserViewSet(UserCreateView, viewsets.ModelViewSet):
serializer_class = settings.SERIALIZERS.user
queryset = User.objects.all()
permission_classes = [permissions.IsAuthenticated]
permission_classes = [CurrentUserOrAdmin]
token_generator = default_token_generator
def get_permissions(self):
......
......@@ -17,7 +17,7 @@ def get_packages(package):
setup(
name='djoser',
version='1.3.1',
version='1.3.2',
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