gophish/static/js/dist/app/sending_profiles.min.js

1 line
7.3 KiB
JavaScript
Raw Normal View History

var profiles=[];function sendTestEmail(){var e=[];$.each($("#headersTable").DataTable().rows().data(),(function(a,o){e.push({key:unescapeHtml(o[0]),value:unescapeHtml(o[1])})}));var a={template:{},first_name:$("input[name=to_first_name]").val(),last_name:$("input[name=to_last_name]").val(),email:$("input[name=to_email]").val(),position:$("input[name=to_position]").val(),url:"",smtp:{from_address:$("#from").val(),host:$("#host").val(),username:$("#username").val(),password:$("#password").val(),ignore_cert_errors:$("#ignore_cert_errors").prop("checked"),headers:e}};btnHtml=$("#sendTestModalSubmit").html(),$("#sendTestModalSubmit").html('<i class="fa fa-spinner fa-spin"></i> Sending'),api.send_test_email(a).success((function(e){$("#sendTestEmailModal\\.flashes").empty().append('<div style="text-align:center" class="alert alert-success">\t <i class="fa fa-check-circle"></i> Email Sent!</div>'),$("#sendTestModalSubmit").html(btnHtml)})).error((function(e){$("#sendTestEmailModal\\.flashes").empty().append('<div style="text-align:center" class="alert alert-danger">\t <i class="fa fa-exclamation-circle"></i> '+escapeHtml(e.responseJSON.message)+"</div>"),$("#sendTestModalSubmit").html(btnHtml)}))}function save(e){var a={headers:[]};$.each($("#headersTable").DataTable().rows().data(),(function(e,o){a.headers.push({key:unescapeHtml(o[0]),value:unescapeHtml(o[1])})})),a.name=$("#name").val(),a.interface_type=$("#interface_type").val(),a.from_address=$("#from").val(),a.host=$("#host").val(),a.username=$("#username").val(),a.password=$("#password").val(),a.ignore_cert_errors=$("#ignore_cert_errors").prop("checked"),-1!=e?(a.id=profiles[e].id,api.SMTPId.put(a).success((function(e){successFlash("Profile edited successfully!"),load(),dismiss()})).error((function(e){modalError(e.responseJSON.message)}))):api.SMTP.post(a).success((function(e){successFlash("Profile added successfully!"),load(),dismiss()})).error((function(e){modalError(e.responseJSON.message)}))}function dismiss(){$("#modal\\.flashes").empty(),$("#name").val(""),$("#interface_type").val("SMTP"),$("#from").val(""),$("#host").val(""),$("#username").val(""),$("#password").val(""),$("#ignore_cert_errors").prop("checked",!0),$("#headersTable").dataTable().DataTable().clear().draw(),$("#modal").modal("hide")}var dismissSendTestEmailModal=function(){$("#sendTestEmailModal\\.flashes").empty(),$("#sendTestModalSubmit").html("<i class='fa fa-envelope'></i> Send")},deleteProfile=function(e){Swal.fire({title:"Are you sure?",text:"This will delete the sending profile. This can't be undone!",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Delete "+escapeHtml(profiles[e].name),confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1,preConfirm:function(){return new Promise((function(a,o){api.SMTPId.delete(profiles[e].id).success((function(e){a()})).error((function(e){o(e.responseJSON.message)}))}))}}).then((function(e){e.value&&Swal.fire("Sending Profile Deleted!","This sending profile has been deleted!","success"),$('button:contains("OK")').on("click",(function(){location.reload()}))}))};function edit(e){headers=$("#headersTable").dataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]}),$("#modalSubmit").unbind("click").click((function(){save(e)}));var a={};-1!=e?($("#profileModalLabel").text("Edit Sending Profile"),a=profiles[e],$("#name").val(a.name),$("#interface_type").val(a.interface_type),$("#from").val(a.from_address),$("#host").val(a.host),$("#username").val(a.username),$("#password").val(a.password),$("#ignore_cert_errors").prop("checked",a.ignore_cert_errors),$.each(a.headers,(function(e,a){addCustomHeader(a.key,a.value)}))):$("#profileModalLabel").text("New Sending Profile")}function copy(e){$("#modalSubmit").unbind("click").click((function(){save(-1)}));var a;a=profiles[e],$("#name").val("Copy of "+a.name),$("#interface_type").val(a.interface_type),$("#from").val(a.from_address),$("#host").val(a.host),$("#username").val(a.username),$("#password").val(a.password),$("#ignore_cert_errors").prop("checked",a.ignore_cert_errors)}fu