Skip to content

Commit

Permalink
Merge pull request #5 from twetech/Readable-Passwords
Browse files Browse the repository at this point in the history
Readable passwords
  • Loading branch information
o-psi authored Dec 22, 2023
2 parents c8d3f3d + 10b04c7 commit 0077a03
Show file tree
Hide file tree
Showing 7 changed files with 312 additions and 163 deletions.
4 changes: 4 additions & 0 deletions ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,3 +487,7 @@
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Login', log_action = 'View TOTP', log_description = '$session_name viewed login TOTP code for $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $login_id");
}
}

if (isset($_GET['get_readable_pass'])) {
echo GenerateReadablePassword(4);
}
60 changes: 32 additions & 28 deletions client_contact_add_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
while ($row = mysqli_fetch_array($sql)) {
$location_id = intval($row['location_id']);
$location_name = nullable_htmlentities($row['location_name']);
?>
?>
<option value="<?php echo $location_id; ?>"><?php echo $location_name; ?></option>
<?php } ?>

Expand All @@ -137,23 +137,23 @@
<div class="col-md-4">
<div class="form-group">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="contactImportantCheckbox" name="contact_important" value="1" >
<input type="checkbox" class="custom-control-input" id="contactImportantCheckbox" name="contact_important" value="1">
<label class="custom-control-label" for="contactImportantCheckbox">Important</label>
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="contactBillingCheckbox" name="contact_billing" value="1" >
<input type="checkbox" class="custom-control-input" id="contactBillingCheckbox" name="contact_billing" value="1">
<label class="custom-control-label" for="contactBillingCheckbox">Billing</label>
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="contactTechnicalCheckbox" name="contact_technical" value="1" >
<input type="checkbox" class="custom-control-input" id="contactTechnicalCheckbox" name="contact_technical" value="1">
<label class="custom-control-label" for="contactTechnicalCheckbox">Technical</label>
</div>
</div>
Expand Down Expand Up @@ -183,36 +183,40 @@
<input type="text" class="form-control" name="pin" placeholder="Security code or pin">
</div>
</div>
<?php if($config_client_portal_enable == 1) { ?>
<div class="authForm">
<div class="form-group">
<label>Login</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-user-circle"></i></span>
<?php if ($config_client_portal_enable == 1) { ?>
<div class="authForm">
<div class="form-group">
<label>Login</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-user-circle"></i></span>
</div>
<select class="form-control select2 authMethod" name="auth_method">
<option value="">- None -</option>
<option value="local">Local</option>
<option value="azure">Azure</option>
</select>
</div>
<select class="form-control select2 authMethod" name="auth_method">
<option value="">- None -</option>
<option value="local">Local</option>
<option value="azure">Azure</option>
</select>
</div>
</div>

<!-- Password Form Group (Initially hidden) -->
<div class="form-group passwordGroup" style="display: none;">
<label>Password</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-key"></i></span>
</div>
<input type="password" class="form-control" data-toggle="password" name="contact_password" placeholder="Enter a password" autocomplete="new-password">
<div class="input-group-append">
<span class="input-group-text"><i class="fa fa-fw fa-eye"></i></span>
<div class="form-group passwordGroup" style="display: none;">
<label>Password</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-lock"></i></span>
</div>
<input type="password" class="form-control" data-toggle="password" id="password-add" name="password" placeholder="Password" autocomplete="new-password">
<div class="input-group-append">
<span class="input-group-text"><i class="fa fa-fw fa-eye"></i></span>
</div>
<div class="input-group-append">
<button type="button" class="btn btn-default" onclick="generatePassword('add')">
<i class="fa fa-fw fa-question"></i>
</button>
</div>
</div>
</div>
</div>
</div>
<?php } ?>

</div>
Expand Down
24 changes: 24 additions & 0 deletions client_contact_details.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,30 @@ function updateContactNotes(contact_id) {

<!-- JavaScript to Show/Hide Password Form Group -->
<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
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() {
$('.authMethod').on('change', function() {
var $form = $(this).closest('.authForm');
Expand Down
Loading

0 comments on commit 0077a03

Please sign in to comment.