mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 08:45:12 +02:00
Credential store
This commit is contained in:
parent
22d936d4f3
commit
e1bf12a1fb
@ -49,16 +49,21 @@ if (! check_acl($config['id_user'], 0, 'PM')) {
|
|||||||
// Required files.
|
// Required files.
|
||||||
ui_require_css_file('credential_store');
|
ui_require_css_file('credential_store');
|
||||||
require_once $config['homedir'].'/include/functions_credential_store.php';
|
require_once $config['homedir'].'/include/functions_credential_store.php';
|
||||||
|
require_once $config['homedir'].'/include/functions_io.php';
|
||||||
|
|
||||||
if (is_ajax()) {
|
if (is_ajax()) {
|
||||||
$draw = get_parameter('draw', 0);
|
$draw = get_parameter('draw', 0);
|
||||||
$filter = get_parameter('filter', []);
|
$filter = get_parameter('filter', []);
|
||||||
$get_key = get_parameter('get_key', 0);
|
$get_key = get_parameter('get_key', 0);
|
||||||
|
$new_form = get_parameter('new_form', 0);
|
||||||
$new_key = get_parameter('new_key', 0);
|
$new_key = get_parameter('new_key', 0);
|
||||||
$update_key = get_parameter('update_key', 0);
|
$update_key = get_parameter('update_key', 0);
|
||||||
$delete_key = get_parameter('delete_key', 0);
|
$delete_key = get_parameter('delete_key', 0);
|
||||||
|
|
||||||
|
if ($new_form) {
|
||||||
|
echo print_inputs();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
if ($delete_key) {
|
if ($delete_key) {
|
||||||
$identifier = get_parameter('identifier', null);
|
$identifier = get_parameter('identifier', null);
|
||||||
@ -130,6 +135,9 @@ if (is_ajax()) {
|
|||||||
$values = [];
|
$values = [];
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
$values[$key] = base64_decode($value);
|
$values[$key] = base64_decode($value);
|
||||||
|
if ($key == 'identifier') {
|
||||||
|
$values[$key] = preg_replace('/\s+/', '-', trim($values[$key]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$identifier = $values['identifier'];
|
$identifier = $values['identifier'];
|
||||||
@ -318,8 +326,7 @@ try {
|
|||||||
|
|
||||||
// Auxiliar div.
|
// Auxiliar div.
|
||||||
$new = '<div id="new_key" style="display: none"><form id="form_new">';
|
$new = '<div id="new_key" style="display: none"><form id="form_new">';
|
||||||
$new .= print_inputs();
|
$new .= '</form></div>';
|
||||||
$new .= '</form> </div>';
|
|
||||||
$details = '<div id="info_key" style="display: none"><form id="form_update">';
|
$details = '<div id="info_key" style="display: none"><form id="form_update">';
|
||||||
$details .= '</form></div>';
|
$details .= '</form></div>';
|
||||||
$aux = '<div id="aux" style="display: none"></div>';
|
$aux = '<div id="aux" style="display: none"></div>';
|
||||||
@ -386,7 +393,7 @@ echo '</div>';
|
|||||||
if (!failed) {
|
if (!failed) {
|
||||||
dt_<?php echo $table_id; ?>.draw(0);
|
dt_<?php echo $table_id; ?>.draw(0);
|
||||||
$(".ui-dialog-content").dialog("close");
|
$(".ui-dialog-content").dialog("close");
|
||||||
$('.ui-dialog-content').remove();
|
cleanupDOM();
|
||||||
} else {
|
} else {
|
||||||
$(this).dialog('close');
|
$(this).dialog('close');
|
||||||
}
|
}
|
||||||
@ -407,7 +414,8 @@ echo '</div>';
|
|||||||
text: '<?php echo __('Cancel'); ?>',
|
text: '<?php echo __('Cancel'); ?>',
|
||||||
click: function(e) {
|
click: function(e) {
|
||||||
$(this).dialog('close');
|
$(this).dialog('close');
|
||||||
$(this).remove();
|
cleanupDOM();
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -464,7 +472,7 @@ echo '</div>';
|
|||||||
text: '<?php echo __('Cancel'); ?>',
|
text: '<?php echo __('Cancel'); ?>',
|
||||||
click: function(e) {
|
click: function(e) {
|
||||||
$(this).dialog('close');
|
$(this).dialog('close');
|
||||||
$(this).remove();
|
cleanupDOM();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -503,6 +511,15 @@ echo '</div>';
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cleanupDOM() {
|
||||||
|
$('#div-identifier').empty();
|
||||||
|
$('#div-product').empty();
|
||||||
|
$('#div-username').empty();
|
||||||
|
$('#div-password').empty();
|
||||||
|
$('#div-extra_1').empty();
|
||||||
|
$('#div-extra_2').empty();
|
||||||
|
}
|
||||||
|
|
||||||
function calculate_inputs() {
|
function calculate_inputs() {
|
||||||
if ($('#product :selected').val() == "CUSTOM") {
|
if ($('#product :selected').val() == "CUSTOM") {
|
||||||
$('#div-username label').text('<?php echo __('Username'); ?>');
|
$('#div-username label').text('<?php echo __('Username'); ?>');
|
||||||
@ -528,11 +545,21 @@ echo '</div>';
|
|||||||
|
|
||||||
function add_key() {
|
function add_key() {
|
||||||
// Clear form.
|
// Clear form.
|
||||||
$('#form_new :input').each(function() {
|
$('#form_update').empty();
|
||||||
$(this).val('')
|
$('#form_update').html('Loading...');
|
||||||
});
|
$.ajax({
|
||||||
|
method: 'post',
|
||||||
|
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||||
|
data: {
|
||||||
|
page: 'godmode/groups/credential_store',
|
||||||
|
new_form: 1
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
$('#form_new').html(data);
|
||||||
$('#id_group').val(0);
|
$('#id_group').val(0);
|
||||||
$('#product').val('CUSTOM');
|
// By default AWS.
|
||||||
|
$('#product').val('AWS');
|
||||||
|
calculate_inputs();
|
||||||
|
|
||||||
$('#product').on('change', function() {
|
$('#product').on('change', function() {
|
||||||
calculate_inputs()
|
calculate_inputs()
|
||||||
@ -555,7 +582,7 @@ echo '</div>';
|
|||||||
text: "<?php echo __('Cancel'); ?>",
|
text: "<?php echo __('Cancel'); ?>",
|
||||||
click: function(e) {
|
click: function(e) {
|
||||||
$(this).dialog('close');
|
$(this).dialog('close');
|
||||||
$(this).remove();
|
cleanupDOM();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -564,6 +591,8 @@ echo '</div>';
|
|||||||
click: function(e) {
|
click: function(e) {
|
||||||
var values = {};
|
var values = {};
|
||||||
|
|
||||||
|
console.log($('#form_new'));
|
||||||
|
|
||||||
$('#form_new :input').each(function() {
|
$('#form_new :input').each(function() {
|
||||||
values[this.name] = btoa($(this).val());
|
values[this.name] = btoa($(this).val());
|
||||||
});
|
});
|
||||||
@ -589,6 +618,10 @@ echo '</div>';
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
|
||||||
$("#submit-create").on('click', function(){
|
$("#submit-create").on('click', function(){
|
||||||
|
@ -268,6 +268,7 @@ function print_inputs($values=null)
|
|||||||
'value' => $values['identifier'],
|
'value' => $values['identifier'],
|
||||||
'disabled' => (bool) $values['identifier'],
|
'disabled' => (bool) $values['identifier'],
|
||||||
'return' => true,
|
'return' => true,
|
||||||
|
'script' => 'alert(\'puta\')',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$return .= html_print_input(
|
$return .= html_print_input(
|
||||||
@ -290,9 +291,9 @@ function print_inputs($values=null)
|
|||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'script' => 'calculate_inputs()',
|
'script' => 'calculate_inputs()',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'CUSTOM' => __('Custom'),
|
// 'CUSTOM' => __('Custom'),
|
||||||
'AWS' => __('Aws'),
|
'AWS' => __('Aws'),
|
||||||
'AZURE' => __('Azure'),
|
// 'AZURE' => __('Azure'),
|
||||||
// 'GOOGLE' => __('Google'),
|
// 'GOOGLE' => __('Google'),
|
||||||
],
|
],
|
||||||
'selected' => $values['product'],
|
'selected' => $values['product'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user