Beispiel #1
0
 def partial_update(self, request):
     """Update logged in user profile"""
     instance = self.get_object()
     serializer = self.get_serializer(instance, data=request.data, partial=True)
     serializer.is_valid(raise_exception=True)
     serializer.save()
     return response.Ok(serializer.data)
Beispiel #2
0
 def password_reset(self, request):
     serializer = self.get_serializer(data=request.data)
     serializer.is_valid(raise_exception=True)
     user = user_services.get_user_by_email(serializer.data['email'])
     if user:
         services.send_password_reset_mail(user)
     return response.Ok({'message': 'Further instructions will be sent to the email if it exists'})
Beispiel #3
0
 def login(self, request):
     serializer = self.get_serializer(data=request.data)
     serializer.is_valid(raise_exception=True)
     user = get_and_authenticate_user(**serializer.validated_data)
     data = serializers.AuthUserSerializer(user).data
     return response.Ok(data)
Beispiel #4
0
 def list(self, request):
     """Get logged in user profile"""
     serializer = self.get_serializer(self.get_object())
     return response.Ok(serializer.data)
Beispiel #5
0
 def logout(self, request):
     """
     Calls Django logout method; Does not work for UserTokenAuth.
     """
     logout(request)
     return response.Ok({"success": "Successfully logged out."})