fix add target modal

This commit is contained in:
Yogesh Ojha
2023-09-25 08:54:19 +05:30
parent d0751a4fb8
commit 995755fc97
3 changed files with 12 additions and 5 deletions
+5 -1
View File
@@ -543,13 +543,17 @@ class AddTarget(APIView):
h1_team_handle = data.get('h1_team_handle')
description = data.get('description')
domain_name = data.get('domain_name')
slug = data.get('slug')
# Validate domain name
if not validators.domain(domain_name):
return Response({'status': False, 'message': 'Invalid domain or IP'})
project = Project.objects.get(slug=slug)
# Create domain object in DB
domain, _ = Domain.objets.get_or_create(name=domain_name)
domain, _ = Domain.objects.get_or_create(name=domain_name)
domain.project = project
domain.h1_team_handle = h1_team_handle
domain.description = description
if not domain.insert_date:
+6 -4
View File
@@ -1871,18 +1871,20 @@ function add_quick_target() {
var domain_name = $('#target_name_modal').val();
var description = $('#target_description_modal').val();
var h1_handle = $('#h1_handle_modal').val();
add_target(domain_name, h1_handle = h1_handle, description = description);
var current_slug = document.querySelector('input[name="current_project"]').value;
add_target(domain_name, current_slug, h1_handle = h1_handle, description = description);
}
function add_target(domain_name, h1_handle = null, description = null) {
function add_target(domain_name, current_slug, h1_handle = null, description = null) {
// this function will add domain_name as target
console.log('Adding new target ' + domain_name)
const add_api = '/api/add/target/?format=json';
const data = {
'domain_name': domain_name,
'h1_team_handle': h1_handle,
'description': description
'description': description,
'slug': current_slug
};
swal.queue([{
title: 'Add Target',
@@ -1916,7 +1918,7 @@ function add_target(domain_name, h1_handle = null, description = null) {
padding: '2em',
showLoaderOnConfirm: true,
preConfirm: function() {
window.location = `/scan/start/${data.domain_id}`;
window.location = `/scan/${current_slug}/start/${data.domain_id}`;
}
}]);
} else {
+1
View File
@@ -63,6 +63,7 @@
{# top nav begins #}
{% include 'base/_items/top_nav.html' %}
{# top nav ends #}
<input type="hidden" name="current_project" value="{{current_project.slug}}">
<div class="content-page">
<div class="content">
<div class="container-fluid">