Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions includes/core/load.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ function(teampassUser) {
}
);
}).then(function() {
if (store.get('teampassSettings') === undefined || parseInt(store.get('teampassSettings').enable_tasks_manager) === 0) {
if (storeSession.get('teampassSettings') === undefined || parseInt(storeSession.get('teampassSettings').enable_tasks_manager) === 0) {
if (debugJavascript === true) {
console.log('Now sending emails');
}
Expand Down Expand Up @@ -541,7 +541,7 @@ function(data) {
progressBar: true
}
);
} else if (parseInt($('#profile-password-complex').val()) >= parseInt(store.get('teampassSettings').personal_saltkey_security_level)) {
} else if (parseInt($('#profile-password-complex').val()) >= parseInt(storeSession.get('teampassSettings').personal_saltkey_security_level)) {
$('#button_do_user_change_password').removeClass('hidden');
$('#button_do_pwds_checks').remove();
toastr.remove();
Expand Down Expand Up @@ -1220,7 +1220,7 @@ function(data) {
// SHow form
$('#dialog-admin-change-user-password').addClass('hidden');

store.set(
storeSession.set(
'teampassUser', {
admin_user_password: '',
admin_user_email: '',
Expand Down Expand Up @@ -1635,9 +1635,9 @@ function(data) {
// except sensitive data
var sensitiveData = ['ldap_hosts','ldap_username','ldap_password','ldap_bdn','email','bck_script_passkey'];

store.remove("teampassSettings");
storeSession.remove("teampassSettings");

store.update(
storeSession.update(
'teampassSettings', {},
function(teampassSettings) {
$.each(data, function(key, value) {
Expand Down
22 changes: 11 additions & 11 deletions includes/core/login.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ function(teampassUser) {
});

// Ensure session is ready in case of disconnection
const teampassSettings = store.get('teampassSettings');
const teampassSettings = storeSession.get('teampassSettings');
if (teampassSettings === null || typeof teampassSettings === 'undefined' || Object.keys(teampassSettings).length === 0) {
store.set(
storeSession.set(
'teampassSettings', {},
function(teampassSettings) {}
);
Expand Down Expand Up @@ -613,10 +613,10 @@ function launchIdentify(isDuo, redirect, psk, oauth2 = false) {
}

// Clear localstorage
store.remove('teampassApplication');
store.remove('teampassSettings');
storeSession.remove('teampassApplication');
storeSession.remove('teampassSettings');
store.remove('teampassUser');
store.remove('teampassItem');
storeSession.remove('teampassItem');

//create random string
var randomstring = CreateRandomString(10);
Expand Down Expand Up @@ -1082,10 +1082,10 @@ function(data) {
* @return void
*/
function showMFAMethod() {
var twoFaMethods = (parseInt(store.get('teampassSettings').google_authentication) === 1 ? 1 : 0) +
(parseInt(store.get('teampassSettings').agses_authentication_enabled) === 1 ? 1 : 0) +
(parseInt(store.get('teampassSettings').duo) === 1 ? 1 : 0) +
(parseInt(store.get('teampassSettings').yubico_authentication) === 1 ? 1 : 0);
var twoFaMethods = (parseInt(storeSession.get('teampassSettings').google_authentication) === 1 ? 1 : 0) +
(parseInt(storeSession.get('teampassSettings').agses_authentication_enabled) === 1 ? 1 : 0) +
(parseInt(storeSession.get('teampassSettings').duo) === 1 ? 1 : 0) +
(parseInt(storeSession.get('teampassSettings').yubico_authentication) === 1 ? 1 : 0);

if (twoFaMethods > 1) {
// Show only expected MFA
Expand Down Expand Up @@ -1145,9 +1145,9 @@ function showMFAMethod() {
// Show only expected MFA
$('#2fa_methods_selector').addClass('hidden');
// One 2FA method is expected
if (parseInt(store.get('teampassSettings').google_authentication) === 1) {
if (parseInt(storeSession.get('teampassSettings').google_authentication) === 1) {
$('#div-2fa-google').removeClass('hidden');
} else if (parseInt(store.get('teampassSettings').yubico_authentication) === 1) {
} else if (parseInt(storeSession.get('teampassSettings').yubico_authentication) === 1) {
$('#div-2fa-yubico').removeClass('hidden');
}
$('#login').focus();
Expand Down
9 changes: 5 additions & 4 deletions includes/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,19 +257,20 @@ function decodeQueryReturn(data, key, fileName = '', functionName = '')
*/
function browserSession(action, name, data)
{
const storeType = name.includes('teampass') ? storeSession : store;
// Initialize the session
if (action === 'init') {
if (store.get(name) === 'undefined'
|| store.get(name) === undefined
if (storeType.get(name) === 'undefined'
|| storeType.get(name) === undefined
) {
store.set(
storeType.set(
name,
data
);
} else {
// Ensure all entries exist
$(data).each(function(value, key) {
store.update(
storeType.update(
name,
function(bSession)
{
Expand Down
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,7 @@
<!-- Toastr -->
<script type="text/javascript" src="plugins/toastr/toastr.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
<!-- STORE.JS -->
<script type="text/javascript" src="plugins/store.js/dist/store.everything.session.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
<script type="text/javascript" src="plugins/store.js/dist/store.everything.min.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
<!-- cryptojs-aesphp -->
<script type="text/javascript" src="includes/libraries/cryptojs/crypto-js.js?v=<?php echo TP_VERSION . '.' . TP_VERSION_MINOR; ?>"></script>
Expand Down
2 changes: 1 addition & 1 deletion pages/export.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<script type='text/javascript'>
// Prepare list of folders
$('.select2').val('');
/*$.each(store.get('teampassApplication').foldersList, function(index, item) {
/*$.each(storeSession.get('teampassApplication').foldersList, function(index, item) {
$('#export-folders').append('<option value="' + item.id + '">' + item.title + '</option>');
});*/
$('#export-folders').append(store.get('teampassUser').folders);
Expand Down
9 changes: 0 additions & 9 deletions pages/fields.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -794,15 +794,6 @@ function(data) {
}
});

/*// Store some values
store.update(
'teampassApplication',
function(teampassApplication)
{
teampassApplication.numberOfCategories = positionCategory + 1;
}
);*/

$('.overlay').addClass('hidden');

// Display
Expand Down
8 changes: 4 additions & 4 deletions pages/folders.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ function(data) {

// store list of folders

store.update(
storeSession.update(
'teampassApplication',
function(teampassApplication) {
teampassApplication.foldersSelect = foldersSelect;
Expand All @@ -484,7 +484,7 @@ function(teampassApplication) {
complexity += '<option value="' + option.value + '">' + option.text + '</option>';
});

store.update(
storeSession.update(
'teampassApplication',
function(teampassApplication) {
teampassApplication.complexityOptions = complexity;
Expand Down Expand Up @@ -688,11 +688,11 @@ function(data) {
'</div>' +
'<div class="form-group ml-2">' +
'<label for="folder-edit-parent"><?php echo $lang->get('parent'); ?></label><br>' +
'<select id="folder-edit-parent" class="form-control form-item-control select2 clear-me">' + store.get('teampassApplication').foldersSelect + '</select>' +
'<select id="folder-edit-parent" class="form-control form-item-control select2 clear-me">' + storeSession.get('teampassApplication').foldersSelect + '</select>' +
'</div>' +
'<div class="form-group ml-2">' +
'<label for="folder-edit-complexity"><?php echo $lang->get('password_minimal_complexity_target'); ?></label><br>' +
'<select id="folder-edit-complexity" class="form-control form-item-control select2 clear-me">' + store.get('teampassApplication').complexityOptions + '</select>' +
'<select id="folder-edit-complexity" class="form-control form-item-control select2 clear-me">' + storeSession.get('teampassApplication').complexityOptions + '</select>' +
'</div>' +
'<div class="form-group ml-2">' +
'<label for="folder-edit-renewal"><?php echo $lang->get('renewal_delay'); ?></label>' +
Expand Down
26 changes: 13 additions & 13 deletions pages/import.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
key: '<?php echo $session->get('key'); ?>'
},
function(data) {
store.update(
storeSession.update(
'teampassApplication',
function(teampassApplication) {
teampassApplication.uploadedFileId = data[0].token;
Expand Down Expand Up @@ -185,7 +185,7 @@ function(teampassApplication) {
$('#import-csv-attach-pickfile-csv-text')
.text(file.name + ' (' + plupload.formatSize(file.size) + ')');

store.update(
storeSession.update(
'teampassApplication',
function(teampassApplication) {
teampassApplication.uploadedFileId = data.operation_id;
Expand Down Expand Up @@ -232,7 +232,7 @@ function(teampassApplication) {
$('#import-csv-attach-pickfile-csv-text').val('');
$('.import-csv-cb').iCheck('uncheck');

store.update(
storeSession.update(
'teampassApplication',
function(teampassApplication) {
teampassApplication.uploadType = '';
Expand All @@ -246,7 +246,7 @@ function(teampassApplication) {
$('#import-keepass-attach-pickfile-keepass-text').text('');
$('.import-keepass-cb').iCheck('uncheck');

store.update(
storeSession.update(
'teampassApplication',
function(teampassApplication) {
teampassApplication.uploadType = '';
Expand All @@ -266,7 +266,7 @@ function(teampassApplication) {
// What importation is on-going
var importTask = $('#import-type').find('.active').text().toLowerCase();

store.update(
storeSession.update(
'teampassApplication',
function(teampassApplication) {
teampassApplication.uploadType = importTask;
Expand Down Expand Up @@ -305,14 +305,14 @@ function ImportCSV() {
toastr.info('<?php echo $lang->get('reading_file'); ?><i class="fa-solid fa-ellipsis fa-2x fa-fade ml-2"></i>');

if (debugJavascript === true) {
console.log("file: "+store.get('teampassApplication').uploadedFileId+" -- Folder id: "+$('#import-csv-target-folder').val());
console.log("file: "+storeSession.get('teampassApplication').uploadedFileId+" -- Folder id: "+$('#import-csv-target-folder').val());
}

// Perform query
$.post(
"sources/import.queries.php", {
type: "import_file_format_csv",
file: store.get('teampassApplication').uploadedFileId,
file: storeSession.get('teampassApplication').uploadedFileId,
folder_id: $('#import-csv-target-folder').val(),
key: '<?php echo $session->get('key'); ?>'
},
Expand All @@ -323,7 +323,7 @@ function(data) {
}

// CLear
store.update(
storeSession.update(
'teampassApplication',
function(teampassApplication) {
teampassApplication.uploadedFileId = '';
Expand Down Expand Up @@ -798,7 +798,7 @@ function(response) {
key: '<?php echo $session->get('key'); ?>'
},
function(data) {
store.update(
storeSession.update(
'teampassApplication',
function(teampassApplication) {
teampassApplication.uploadedFileId = data[0].token;
Expand All @@ -817,7 +817,7 @@ function(teampassApplication) {

up.settings.multipart_params.PHPSESSID = "<?php echo session_id(); ?>";
up.settings.multipart_params.type_upload = "import_items_from_keepass";
up.settings.multipart_params.user_token = store.get('teampassApplication').uploadedFileId;
up.settings.multipart_params.user_token = storeSession.get('teampassApplication').uploadedFileId;
},
FileUploaded: function(upldr, file, object) {
var data = prepareExchangedData(object.response, "decode", "<?php echo $session->get('key'); ?>");
Expand Down Expand Up @@ -848,7 +848,7 @@ function(teampassApplication) {
$('#import-keepass-attach-pickfile-keepass-text')
.text(file.name + ' (' + plupload.formatSize(file.size) + ')');

store.update(
storeSession.update(
'teampassApplication',
function(teampassApplication) {
teampassApplication.uploadedFileId = data.operation_id;
Expand Down Expand Up @@ -898,7 +898,7 @@ function launchKeepassItemsImport() {
ProcessInProgress = true;

data = {
'file': store.get('teampassApplication').uploadedFileId,
'file': storeSession.get('teampassApplication').uploadedFileId,
'folder-id': parseInt($('#import-keepass-target-folder').val()),
}
if (debugJavascript === true) {
Expand Down Expand Up @@ -1086,7 +1086,7 @@ function(data) {
$('#import-keepass-attach-pickfile-keepass-text').text('');
$('.import-keepass-cb').iCheck('uncheck');

store.update(
storeSession.update(
'teampassApplication',
function(teampassApplication) {
teampassApplication.uploadType = '';
Expand Down
Loading