mirror of
https://github.com/itflow-org/itflow
synced 2026-03-01 03:14:52 +00:00
Logins JS Cleanup
- Remove old JS - Standardize generate password JS style to match existing - Move JS functions to own files
This commit is contained in:
4
ajax.php
4
ajax.php
@@ -333,7 +333,7 @@ if (isset($_GET['share_generate_link'])) {
|
|||||||
'body' => $body
|
'body' => $body
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
$mail = addToMailQueue($mysqli, $data);
|
$mail = addToMailQueue($mysqli, $data);
|
||||||
|
|
||||||
if ($mail !== true) {
|
if ($mail !== true) {
|
||||||
@@ -499,5 +499,5 @@ if (isset($_GET['get_totp_token_via_id'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET['get_readable_pass'])) {
|
if (isset($_GET['get_readable_pass'])) {
|
||||||
echo GenerateReadablePassword(4);
|
echo json_encode(GenerateReadablePassword(4));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,63 +177,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<!-- Include script to get TOTP code via the login ID -->
|
||||||
// TODO: Remove this
|
<script src="js/logins_show_otp_via_id.js"></script>
|
||||||
function showOTP(id, secret) {
|
|
||||||
//Send a GET request to ajax.php as ajax.php?get_totp_token=true&totp_secret=SECRET
|
|
||||||
jQuery.get(
|
|
||||||
"ajax.php", {
|
|
||||||
get_totp_token: 'true',
|
|
||||||
totp_secret: secret
|
|
||||||
},
|
|
||||||
function(data) {
|
|
||||||
//If we get a response from post.php, parse it as JSON
|
|
||||||
const token = JSON.parse(data);
|
|
||||||
|
|
||||||
document.getElementById("otp_" + id).innerText = token
|
<!-- Include script to generate readable passwords for login entries -->
|
||||||
|
<script src="js/logins_generate_password.js"></script>
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function showOTPViaLoginID(login_id) {
|
|
||||||
// Send a GET request to ajax.php as ajax.php?get_totp_token_via_id=true&login_id=ID
|
|
||||||
jQuery.get(
|
|
||||||
"ajax.php", {
|
|
||||||
get_totp_token_via_id: 'true',
|
|
||||||
login_id: login_id
|
|
||||||
},
|
|
||||||
function(data) {
|
|
||||||
//If we get a response from post.php, parse it as JSON
|
|
||||||
const token = JSON.parse(data);
|
|
||||||
|
|
||||||
document.getElementById("otp_" + login_id).innerText = token
|
|
||||||
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function generatePassword() {
|
|
||||||
document.getElementById("password").value = "<?php echo generateReadablePassword(3); ?>"
|
|
||||||
}
|
|
||||||
|
|
||||||
function generatePassword() {
|
|
||||||
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;
|
|
||||||
|
|
||||||
document.getElementById("password").value = password;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
xhr.send();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|||||||
14
js/logins_generate_password.js
Normal file
14
js/logins_generate_password.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
function generatePassword(login_id) {
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
document.getElementById("password").value = password;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
16
js/logins_show_otp_via_id.js
Normal file
16
js/logins_show_otp_via_id.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
function showOTPViaLoginID(login_id) {
|
||||||
|
// Send a GET request to ajax.php as ajax.php?get_totp_token_via_id=true&login_id=ID
|
||||||
|
jQuery.get(
|
||||||
|
"ajax.php", {
|
||||||
|
get_totp_token_via_id: 'true',
|
||||||
|
login_id: login_id
|
||||||
|
},
|
||||||
|
function(data) {
|
||||||
|
//If we get a response from post.php, parse it as JSON
|
||||||
|
const token = JSON.parse(data);
|
||||||
|
|
||||||
|
document.getElementById("otp_" + login_id).innerText = token
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user