def send_test_email(self, request, *args, **kwargs): data = request.data send_smtp_test_email.delay([data['email']]) resp = ResponseBody() resp.data = [request.data] resp.code = code.success return resp
def get_sec_group(self, request, *args, **kwargs): queryset = User.objects.filter(groups__name__in=['安全组']) serializer = UserReturnSerializer(queryset, many=True) resp = ResponseBody() resp.data = serializer.data resp.code = code.success return resp
def get_user_info(self, request, *args, **kwargs): resp = ResponseBody() if request.user: user_data = UserReturnSerializer(request.user).data resp.code = code.success resp.data = user_data return resp
def post(self, request, *args, **kwargs): resp = super(ObtainJWT, self).post(request, *args, **kwargs) resp_body = ResponseBody() if resp.status_code == status.HTTP_200_OK: user_obj = User.objects.get(email=request.data['email']) user_obj.last_login = timezone.datetime.now() user_obj.save() resp_body.code = code.success resp_body.data['token'] = resp.data['token'] resp.data = resp_body return resp
def send_vul_todo_email(self, request, *args, **kwargs): vul_id = request.query_params['id'] message = request.query_params['message'] obj = VulWorkflow.objects.get(id=vul_id) if obj.vulnerability.status == 1: to_addr = [user.email for user in obj.asset.pics.all()] else: to_addr = [obj.vulnerability.reporter.email] vul_link = f"http://localhost:9528/#/vuls/workflow/{vul_id}" send_vul_todo_email.delay(to_addr, obj, vul_link, message) resp = ResponseBody() resp.data = obj.title resp.code = code.success return resp
def send_pen_todo_email(self, request, *args, **kwargs): pen_id = request.query_params['id'] obj = PenetrationTestTicket.objects.get(id=pen_id) message = '' if obj.status == 0: message = "您的工单被拒绝" to_addr = [obj.creator.email] url = f"http://{request.META['HTTP_HOST']}/#/tickets/own" else: to_addr = [user.email for user in obj.transactors.all()] url = f"http://{request.META['HTTP_HOST']}/#/tickets/todo" print(to_addr) send_pen_todo_email.delay(to_addr, url, obj.title, obj.creator.full_name, message) resp = ResponseBody() resp.data = obj.title resp.code = code.success return resp
def get_types(self, request, *args, **kwargs): resp = ResponseBody() data = Vulnerability.VUL_TYPES resp.code = code.success resp.data = data return resp
def logout(self, request, *args, **kwargs): return ResponseBody()