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)
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'})
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)
def list(self, request): """Get logged in user profile""" serializer = self.get_serializer(self.get_object()) return response.Ok(serializer.data)
def logout(self, request): """ Calls Django logout method; Does not work for UserTokenAuth. """ logout(request) return response.Ok({"success": "Successfully logged out."})