mirror of
https://github.com/itflow-org/itflow
synced 2026-07-24 17:30:43 +00:00
Feature: Add new js function to retrieve and Audit log Password reveals, still need to get the edit modals
This commit is contained in:
43
agent/js/credential_show_password_via_id.js
Normal file
43
agent/js/credential_show_password_via_id.js
Normal file
@@ -0,0 +1,43 @@
|
||||
function showPasswordViaCredentialID(button, credential_id) {
|
||||
// Send a GET request to ajax.php as ajax.php?get_credential_via_id=true&credential_id=ID
|
||||
jQuery.get(
|
||||
"ajax.php", {
|
||||
get_credential_via_id: 'true',
|
||||
credential_id: credential_id
|
||||
},
|
||||
function(data) {
|
||||
const credential = JSON.parse(data);
|
||||
|
||||
// (Re)create the popover with the fetched password and show it
|
||||
// trigger: focus dismisses it when the user clicks away
|
||||
jQuery(button).popover('dispose').popover({
|
||||
content: credential.password,
|
||||
placement: 'top',
|
||||
trigger: 'focus'
|
||||
}).popover('show');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function copyPasswordViaCredentialID(button, credential_id) {
|
||||
jQuery.get(
|
||||
"ajax.php", {
|
||||
get_credential_via_id: 'true',
|
||||
credential_id: credential_id
|
||||
},
|
||||
function(data) {
|
||||
const credential = JSON.parse(data);
|
||||
|
||||
navigator.clipboard.writeText(credential.password).then(function() {
|
||||
// Flash "Copied!" tooltip, matching the ClipboardJS success handler in app.js
|
||||
jQuery(button).tooltip('hide')
|
||||
.attr('data-original-title', 'Copied!')
|
||||
.tooltip('show');
|
||||
|
||||
setTimeout(function() {
|
||||
jQuery(button).tooltip('hide');
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user