Skip to content

Commit

Permalink
Merge pull request #915 from wrongecho/contact-pw-generator-bugfix
Browse files Browse the repository at this point in the history
Bugfix: Contact generated passwords are in quotes
  • Loading branch information
johnnyq authored Mar 18, 2024
2 parents 064629d + d29726f commit aed46a3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 30 deletions.
29 changes: 13 additions & 16 deletions client_contact_details.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,12 @@
<td><?php echo $asset_type; ?></td>
<td>
<?php echo $asset_make; ?>
<div class="mt-0">
<div class="mt-0">
<small class="text-muted"><?php echo $asset_model; ?></small>
</div>
</td>
<td><?php echo $asset_serial_display; ?></td>

<td><?php echo $asset_install_date_display; ?></td>
<td><?php echo $asset_status; ?></td>
<td>
Expand Down Expand Up @@ -580,26 +580,23 @@ function updateContactNotes(contact_id) {
<script>

function generatePassword(type, id) {
var url = '/ajax.php?get_readable_pass=true';

// Make an AJAX request to the server
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);

xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var password = xhr.responseText;

// Set the password value based on the type
// Send a GET request to ajax.php as ajax.php?get_readable_pass=true
jQuery.get(
"ajax.php", {
get_readable_pass: 'true'
},
function(data) {
//If we get a response from post.php, parse it as JSON
const password = JSON.parse(data);

// Set the password value to the correct modal, based on the type
if (type == "add") {
document.getElementById("password-add").value = password;
} else if (type == "edit") {
console.log("password-edit-"+id.toString());
document.getElementById("password-edit-"+id.toString()).value = password;
}
}
};
xhr.send();
);
}

$(document).ready(function() {
Expand Down
25 changes: 11 additions & 14 deletions client_contacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,26 +293,23 @@
<script>

function generatePassword(type, id) {
var url = '/ajax.php?get_readable_pass=true';

// Make an AJAX request to the server
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);

xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var password = xhr.responseText;

// Set the password value based on the type
// Send a GET request to ajax.php as ajax.php?get_readable_pass=true
jQuery.get(
"ajax.php", {
get_readable_pass: 'true'
},
function(data) {
//If we get a response from post.php, parse it as JSON
const password = JSON.parse(data);

// Set the password value to the correct modal, based on the type
if (type == "add") {
document.getElementById("password-add").value = password;
} else if (type == "edit") {
console.log("password-edit-"+id.toString());
document.getElementById("password-edit-"+id.toString()).value = password;
}
}
};
xhr.send();
);
}

$(document).ready(function() {
Expand Down

0 comments on commit aed46a3

Please sign in to comment.