Merge pull request #915 from wrongecho/contact-pw-generator-bugfix

Bugfix: Contact generated passwords are in quotes
This commit is contained in:
Johnny 2024-03-17 22:50:19 -04:00 committed by GitHub
commit aed46a3b21
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 28 deletions

View File

@ -221,12 +221,12 @@ if (isset($_GET['contact_id'])) {
<td><?php echo $asset_type; ?></td> <td><?php echo $asset_type; ?></td>
<td> <td>
<?php echo $asset_make; ?> <?php echo $asset_make; ?>
<div class="mt-0"> <div class="mt-0">
<small class="text-muted"><?php echo $asset_model; ?></small> <small class="text-muted"><?php echo $asset_model; ?></small>
</div> </div>
</td> </td>
<td><?php echo $asset_serial_display; ?></td> <td><?php echo $asset_serial_display; ?></td>
<td><?php echo $asset_install_date_display; ?></td> <td><?php echo $asset_install_date_display; ?></td>
<td><?php echo $asset_status; ?></td> <td><?php echo $asset_status; ?></td>
<td> <td>
@ -580,26 +580,23 @@ if (isset($_GET['contact_id'])) {
<script> <script>
function generatePassword(type, id) { function generatePassword(type, id) {
var url = '/ajax.php?get_readable_pass=true'; // 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);
// Make an AJAX request to the server // Set the password value to the correct modal, based on the type
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
if (type == "add") { if (type == "add") {
document.getElementById("password-add").value = password; document.getElementById("password-add").value = password;
} else if (type == "edit") { } else if (type == "edit") {
console.log("password-edit-"+id.toString());
document.getElementById("password-edit-"+id.toString()).value = password; document.getElementById("password-edit-"+id.toString()).value = password;
} }
} }
}; );
xhr.send();
} }
$(document).ready(function() { $(document).ready(function() {

View File

@ -293,26 +293,23 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<script> <script>
function generatePassword(type, id) { function generatePassword(type, id) {
var url = '/ajax.php?get_readable_pass=true'; // 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);
// Make an AJAX request to the server // Set the password value to the correct modal, based on the type
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
if (type == "add") { if (type == "add") {
document.getElementById("password-add").value = password; document.getElementById("password-add").value = password;
} else if (type == "edit") { } else if (type == "edit") {
console.log("password-edit-"+id.toString());
document.getElementById("password-edit-"+id.toString()).value = password; document.getElementById("password-edit-"+id.toString()).value = password;
} }
} }
}; );
xhr.send();
} }
$(document).ready(function() { $(document).ready(function() {