@@ -264,6 +264,21 @@ function makeBool(val) {
264264 }
265265 return false ;
266266}
267+ function _redactForLog ( url , data ) {
268+ try {
269+ var u = ( url || '' ) . toString ( ) . toLowerCase ( ) ;
270+ // Redact any security-related payloads (passwords, pins, etc.)
271+ if ( u . indexOf ( '/security/' ) !== - 1 ) {
272+ return { redacted : true } ;
273+ }
274+ // Redact common sensitive keys if present
275+ var s = ( typeof data === 'string' ) ? data : JSON . stringify ( data ) ;
276+ if ( typeof s === 'string' && s . match ( / p a s s w o r d | p i n | s e c r e t | t o k e n / i) ) {
277+ return { redacted : true } ;
278+ }
279+ } catch ( e ) { }
280+ return data ;
281+ }
267282// PUT and Delete for ReST calls.
268283jQuery . each ( [ "put" , "delete" ] , function ( i , method ) {
269284 jQuery [ method ] = function ( url , data , callback , type ) {
@@ -343,13 +358,15 @@ jQuery.each(['get', 'put', 'delete', 'post'], function (i, method) {
343358 successCallback = $ . mergeCallbacks ( successCallback , cbShowSuccess ) ;
344359 errorCallback = $ . mergeCallbacks ( errorCallback , cbShowError ) ;
345360 completeCallback = $ . mergeCallbacks ( completeCallback , cbComplete ) ;
346- console . log ( { method : method , url : url , data : typeof data === 'string' ? data : JSON . stringify ( data ) } ) ;
361+ console . log ( { method : method , url : url , data : _redactForLog ( url , ( typeof data === 'string' ? data : JSON . stringify ( data ) ) ) } ) ;
362+ // Treat null like undefined (prevents "?null" from being appended on GET requests)
363+ if ( data === null ) data = undefined ;
347364 return jQuery . ajax ( {
348365 url : serviceUrl ,
349366 type : method ,
350367 dataType : 'json' ,
351368 contentType : 'application/json; charset=utf-8' ,
352- data : typeof data === 'string' ? data : JSON . stringify ( data ) ,
369+ data : typeof data === 'undefined' ? undefined : ( typeof data === ' string' ? data : JSON . stringify ( data ) ) ,
353370 error : errorCallback ,
354371 success : successCallback ,
355372 complete : completeCallback
@@ -421,13 +438,15 @@ jQuery.each(['get', 'put', 'delete', 'post'], function (i, method) {
421438 successCallback = $ . mergeCallbacks ( successCallback , cbShowSuccess ) ;
422439 errorCallback = $ . mergeCallbacks ( errorCallback , cbShowError ) ;
423440 completeCallback = $ . mergeCallbacks ( completeCallback , cbComplete ) ;
424- console . log ( { method : method , url : url , data : typeof data === 'string' ? data : JSON . stringify ( data ) } ) ;
441+ console . log ( { method : method , url : url , data : _redactForLog ( url , ( typeof data === 'string' ? data : JSON . stringify ( data ) ) ) } ) ;
442+ // Treat null like undefined (prevents "?null" from being appended on GET requests)
443+ if ( data === null ) data = undefined ;
425444 return jQuery . ajax ( {
426445 url : serviceUrl ,
427446 type : method ,
428447 dataType : 'json' ,
429448 contentType : 'application/json; charset=utf-8' ,
430- data : typeof data === 'string' ? data : JSON . stringify ( data ) ,
449+ data : typeof data === 'undefined' ? undefined : ( typeof data === ' string' ? data : JSON . stringify ( data ) ) ,
431450 error : errorCallback ,
432451 success : successCallback ,
433452 complete : completeCallback
@@ -482,14 +501,16 @@ jQuery.each(['get', 'put', 'delete', 'post'], function (i, method) {
482501 successCallback = $ . mergeCallbacks ( successCallback , cbShowSuccess ) ;
483502 errorCallback = $ . mergeCallbacks ( errorCallback , cbShowError ) ;
484503 completeCallback = $ . mergeCallbacks ( completeCallback , cbComplete ) ;
485- console . log ( { method : method , url : url , data : typeof data === 'string' ? data : JSON . stringify ( data ) } ) ;
504+ console . log ( { method : method , url : url , data : _redactForLog ( url , ( typeof data === 'string' ? data : JSON . stringify ( data ) ) ) } ) ;
505+ // Treat null like undefined (prevents "?null" from being appended on GET requests)
506+ if ( data === null ) data = undefined ;
486507 return jQuery . ajax ( {
487508 url : serviceUrl ,
488509 type : method ,
489510 dataType : 'binary' ,
490511 processData : false ,
491512 contentType : 'application/json; charset=utf-8' ,
492- data : typeof data === 'string' ? data : JSON . stringify ( data ) ,
513+ data : typeof data === 'undefined' ? undefined : ( typeof data === ' string' ? data : JSON . stringify ( data ) ) ,
493514 cache : false ,
494515 xhrFields : { responseType : 'blob' } ,
495516 error : errorCallback ,
@@ -4333,6 +4354,24 @@ $.pic.modalDialog.closeDialog = function (el) {
43334354 return dlg ;
43344355} ;
43354356$ . pic . modalDialog . createApiError = function ( err , options ) {
4357+ try {
4358+ // For guest-facing security flows, don't show stack traces.
4359+ // Example: /security/unlock invalid password should show a simple message.
4360+ if ( err && err . httpCode === 401 && err . error && typeof err . error . message === 'string' &&
4361+ err . error . message . toLowerCase ( ) . indexOf ( 'invalid admin password' ) !== - 1 ) {
4362+ return $ . pic . modalDialog . createConfirm ( 'dlgIncorrectPassword' , {
4363+ autoOpen : false ,
4364+ height : 'auto' ,
4365+ width : '22rem' ,
4366+ modal : true ,
4367+ title : 'Incorrect Password' ,
4368+ message : '<div class="info-message">Incorrect password.</div>' ,
4369+ buttons : [
4370+ { text : 'Close' , icon : '<i class="far fa-window-close"></i>' , click : function ( ) { $ . pic . modalDialog . closeDialog ( this ) ; } }
4371+ ]
4372+ } ) ;
4373+ }
4374+ } catch ( e ) { }
43364375 var opt = typeof options !== 'undefined' && options !== null ? options : {
43374376 autoOpen : false ,
43384377 height : 'auto' ,
0 commit comments