@@ -383,14 +383,13 @@ function(teampassApplication) {
383
383
$(document).on('click', '#card-item-pwd-show-button', function() {
384
384
if ($(this).hasClass('pwd-shown') === false) {
385
385
$(this).addClass('pwd-shown');
386
- // Prepare data to show
387
- // Is data crypted?
388
- var data = unCryptData($('#hidden-item-pwd').val(), '<?php echo $ session ->get ('key ' ); ?> ');
389
- if (data !== false && data !== undefined) {
390
- $('#hidden-item-pwd').val(
391
- data.password
392
- );
393
- }
386
+
387
+ // Get item password from server
388
+ const item_pwd = getItemPassword(
389
+ 'at_password_shown',
390
+ 'item_id',
391
+ store.get('teampassItem').id
392
+ );
394
393
395
394
// Change class and show spinner
396
395
$('.pwd-show-spinner')
@@ -399,16 +398,9 @@ function(teampassApplication) {
399
398
400
399
// display raw password
401
400
$('#card-item-pwd')
402
- .text($('#hidden-item-pwd').val() )
401
+ .text(item_pwd )
403
402
.addClass('pointer_none');
404
403
405
- // log password is shown
406
- itemLog(
407
- 'at_password_shown',
408
- store.get('teampassItem').id,
409
- $('#card-item-label').text()
410
- );
411
-
412
404
// Autohide
413
405
setTimeout(() => {
414
406
$(this).removeClass('pwd-shown');
@@ -2581,34 +2573,24 @@ function(ret) {
2581
2573
mouseStillDown = false;
2582
2574
showPwdContinuous();
2583
2575
});
2584
- var showPwdContinuous = function() {
2585
- if (mouseStillDown === true) {
2586
- // Prepare data to show
2587
- // Is data crypted?
2588
- var data = unCryptData($('#hidden-item-pwd').val(), '<?php echo $ session ->get ('key ' ); ?> ');
2589
- if (data !== false && data !== undefined) {
2590
- $('#hidden-item-pwd').val(
2591
- data.password
2592
- );
2593
- }
2594
2576
2595
- $('#card-item-pwd')
2596
- .html(
2597
- // XSS Filtering
2598
- $('<span span style="cursor:none;">').text($('#hidden-item-pwd').val()).html()
2599
- );
2577
+ const showPwdContinuous = function() {
2578
+ if (mouseStillDown === true
2579
+ && !$('#card-item-pwd').hasClass('pwd-shown')) {
2580
+
2581
+ // Get item password from server
2582
+ const item_pwd = getItemPassword(
2583
+ 'at_password_shown',
2584
+ 'item_id',
2585
+ store.get('teampassItem').id
2586
+ );
2600
2587
2588
+ $('#card-item-pwd').text(item_pwd);
2589
+ $('#card-item-pwd').addClass('pwd-shown');
2590
+
2591
+ // Auto hide password
2601
2592
setTimeout('showPwdContinuous("card-item-pwd")', 50);
2602
- // log password is shown
2603
- if ($('#card-item-pwd').hasClass('pwd-shown') === false) {
2604
- itemLog(
2605
- 'at_password_shown',
2606
- store.get('teampassItem').id,
2607
- $('#card-item-label').text()
2608
- );
2609
- $('#card-item-pwd').addClass('pwd-shown');
2610
- }
2611
- } else {
2593
+ } else if(mouseStillDown !== true) {
2612
2594
$('#card-item-pwd')
2613
2595
.html('<?php echo $ var ['hidden_asterisk ' ]; ?> ')
2614
2596
.removeClass('pwd-shown');
@@ -3380,6 +3362,14 @@ function(teampassItem) {
3380
3362
}
3381
3363
);
3382
3364
} else {
3365
+ // Get password and fill the field.
3366
+ const item_pwd = getItemPassword(
3367
+ 'at_password_shown_edit_form',
3368
+ 'item_id',
3369
+ store.get('teampassItem').id
3370
+ );
3371
+ $('#form-item-password').val(item_pwd);
3372
+
3383
3373
$('#card-item-visibility').html(store.get('teampassItem').itemVisibility);
3384
3374
$('#card-item-minimum-complexity').html(store.get('teampassItem').itemMinimumComplexity);
3385
3375
@@ -3980,57 +3970,18 @@ function(teampassItem) {
3980
3970
// Send query and get password
3981
3971
var result = '',
3982
3972
error = false;
3983
-
3984
- $.ajax({
3985
- type: "POST",
3986
- async: false,
3987
- url: 'sources/items.queries.php',
3988
- data: 'type=show_item_password&item_key=' + trigger.getAttribute('data-item-key') +
3989
- '&key=<?php echo $ session ->get ('key ' ); ?> ',
3990
- dataType: "",
3991
- success: function(data) {
3992
- //decrypt data
3993
- try {
3994
- data = prepareExchangedData(data, "decode", "<?php echo $ session ->get ('key ' ); ?> ");
3995
- } catch (e) {
3996
- // error
3997
- toastr.remove();
3998
- toastr.warning(
3999
- '<?php echo $ lang ->get ('no_item_to_display ' ); ?> '
4000
- );
4001
- return false;
4002
- }
4003
- if (data.error === true) {
4004
- error = true;
4005
- } else {
4006
- if (data.password_error !== '') {
4007
- error = true;
4008
- } else {
4009
- result = simplePurifier(atob(data.password), false, false, false, false).utf8Decode();
4010
- }
4011
- if (result === '') {
4012
- toastr.info(
4013
- '<?php echo $ lang ->get ('password_is_empty ' ); ?> ',
4014
- '', {
4015
- timeOut: 2000,
4016
- positionClass: 'toast-bottom-right',
4017
- progressBar: true
4018
- }
4019
- );
4020
- }
4021
- }
4022
- }
4023
- });
4024
- return result;
3973
+
3974
+ // Get item password from server
3975
+ const item_pwd = getItemPassword(
3976
+ 'at_password_copied',
3977
+ 'item_key',
3978
+ trigger.getAttribute('data-item-key')
3979
+ );
3980
+
3981
+ return item_pwd;
4025
3982
}
4026
3983
});
4027
- clipboardForPassword.on('success', function(e) {
4028
- itemLog(
4029
- 'at_password_copied',
4030
- e.trigger.dataset.itemId,
4031
- e.trigger.dataset.itemLabel
4032
- );
4033
-
3984
+ clipboardForPassword.on('success', function(e) {
4034
3985
// Warn user about clipboard clear
4035
3986
if (store.get('teampassSettings').clipboard_life_duration === undefined || parseInt(store.get('teampassSettings').clipboard_life_duration) === 0) {
4036
3987
toastr.remove();
@@ -4834,11 +4785,6 @@ function(teampassUser) {
4834
4785
$('#card-item-pwd').after('<i class="fa-solid fa-bell text-orange fa-shake ml-3 delete-after-usage infotip" title="'+data.pwd_encryption_error_message+'"></i>');
4835
4786
}
4836
4787
4837
- // Uncrypt the pwd
4838
- if (data.pw !== undefined) {
4839
- data.pw = simplePurifier(atob(data.pw), false, false, false, false).utf8Decode();
4840
- }
4841
-
4842
4788
// Update hidden variables
4843
4789
store.update(
4844
4790
'teampassItem',
@@ -4901,7 +4847,7 @@ function(teampassItem) {
4901
4847
$('.form-item').removeClass('hidden');
4902
4848
$('#folders-tree-card').addClass('hidden');
4903
4849
}
4904
- $('#pwd-definition-size').val(data.pw.length );
4850
+ $('#pwd-definition-size').val(data.pw_length );
4905
4851
4906
4852
// Prepare card
4907
4853
const itemIcon = (data.fa_icon !== "") ? '<i class="'+data.fa_icon+' mr-1"></i>' : '';
@@ -4914,8 +4860,6 @@ function(teampassItem) {
4914
4860
$('#card-item-description').removeClass('hidden');
4915
4861
}
4916
4862
$('#card-item-pwd').html('<?php echo $ var ['hidden_asterisk ' ]; ?> ');
4917
- $('#hidden-item-pwd, #form-item-suggestion-password').val(data.pw);
4918
- $('#form-item-password, #form-item-password-confirmation, #form-item-server-old-password').val(data.pw);
4919
4863
$('#card-item-login').html(data.login);
4920
4864
$('#form-item-login, #form-item-suggestion-login, #form-item-server-login').val(data.login);
4921
4865
@@ -5179,24 +5123,25 @@ function(teampassItem) {
5179
5123
}
5180
5124
5181
5125
// Prepare clipboard - COPY PASSWORD
5182
- if (data.pw !== '' && store.get('teampassItem').readyToUse === true) {
5126
+ if (data.pw_length > 0 && store.get('teampassItem').readyToUse === true) {
5183
5127
// Delete existing clipboard
5184
5128
if (clipboardForPasswordListItems) {
5185
5129
clipboardForPasswordListItems.destroy();
5186
5130
}
5187
5131
// New clipboard
5188
5132
clipboardForPasswordListItems = new ClipboardJS('#card-item-pwd-button', {
5189
5133
text: function() {
5190
- return (data.pw);
5134
+ // Get item password from server
5135
+ const item_pwd = getItemPassword(
5136
+ 'at_password_copied',
5137
+ 'item_id',
5138
+ data.id
5139
+ );
5140
+
5141
+ return item_pwd;
5191
5142
}
5192
5143
})
5193
5144
.on('success', function(e) {
5194
- itemLog(
5195
- 'at_password_copied',
5196
- store.get('teampassItem').id,
5197
- $('#card-item-label').text()
5198
- );
5199
-
5200
5145
// Warn user about clipboard clear
5201
5146
if (store.get('teampassSettings').clipboard_life_duration === undefined || parseInt(store.get('teampassSettings').clipboard_life_duration) === 0) {
5202
5147
toastr.remove();
@@ -6427,10 +6372,6 @@ function(data) {
6427
6372
);
6428
6373
});
6429
6374
6430
- $('#item-button-password-copy').click(function() {
6431
- $('#form-item-password-confirmation').val($('#form-item-password').val());
6432
- });
6433
-
6434
6375
/**
6435
6376
* On tag badge click, launch the search query
6436
6377
*/
0 commit comments