Exemplo n.º 1
0
    def validate_old_password(self, old_password):
        # old_password = base64.b64decode(old_password).decode('utf8')
        if old_password:
            # 判断原密码是否正确
            verify = UserProfile.check_password(self.instance, old_password)

            if not verify:
                # 原密码不正确
                raise serializers.ValidationError("原密码不正确")
        return old_password
Exemplo n.º 2
0
    def validate_password(self, password):
        # old_password = base64.b64decode(old_password).decode('utf8')
        if password:
            # 判断原密码是否正确
            verify = UserProfile.check_password(self.context['request'].user, password)

            if not verify:
                # 密码不正确
                raise serializers.ValidationError('密码不正确')
                # raise Response({"订单审核状态不存在"}, status=status.HTTP_400_BAD_REQUEST)
        return password