2021-12-05 13:50:34 +01:00
|
|
|
from rest_framework import viewsets
|
|
|
|
|
|
|
|
from users.models import User
|
|
|
|
from users.serializers import UserSerializer
|
2021-12-11 22:01:14 +01:00
|
|
|
from rest_framework import views, exceptions, status, viewsets, permissions, generics
|
|
|
|
from tools.tools import PasswordResetShortcut, PasswordResetConfirmShortcut
|
|
|
|
from django.contrib.auth.tokens import default_token_generator
|
|
|
|
from .serializers import UserPasswordResetSerializer, UserPasswordResetConfirmSerializer
|
2021-12-05 13:50:34 +01:00
|
|
|
|
|
|
|
|
|
|
|
class UserModelViewSet(viewsets.ModelViewSet):
|
|
|
|
queryset = User.objects.all()
|
|
|
|
serializer_class = UserSerializer
|
2021-12-11 22:01:14 +01:00
|
|
|
|
|
|
|
|
|
|
|
class PasswordReset(PasswordResetShortcut, generics.GenericAPIView):
|
|
|
|
"""
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"email": "testowymail@gmail.com"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
"""
|
|
|
|
serializer_class = UserPasswordResetSerializer
|
|
|
|
permission_classes = (permissions.AllowAny, )
|
|
|
|
|
|
|
|
|
|
|
|
class UserPasswordResetConfirmView(PasswordResetConfirmShortcut, generics.GenericAPIView):
|
|
|
|
"""
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"uid": "NYz",
|
|
|
|
"token": "asdasdasd",
|
|
|
|
"code": 123456,
|
|
|
|
"newPassword": "testowe",
|
|
|
|
"repeatNewPassword": "testowe"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
"""
|
|
|
|
serializer_class = UserPasswordResetConfirmSerializer
|
|
|
|
permission_classes = (permissions.AllowAny, )
|
|
|
|
token_generator = default_token_generator
|