@@ -1974,6 +1974,10 @@ export function checkPassword ($theForm) {
19741974 return true ;
19751975}
19761976
1977+ export function shouldShowEmptyPasswordWarning ( form ) : boolean {
1978+ return ( form . find ( '#nopass_1' ) . is ( ':checked' ) && form . data ( 'allowNoPassword' ) === 0 ) ;
1979+ }
1980+
19771981export function onloadChangePasswordEvents ( ) : void {
19781982 /* Handler for hostname type */
19791983 $ ( document ) . on ( 'change' , '#select_pred_hostname' , function ( ) {
@@ -2067,25 +2071,35 @@ export function onloadChangePasswordEvents (): void {
20672071 */
20682072 var thisValue = $ ( this ) . val ( ) ;
20692073
2070- var $msgbox = ajaxShowMessage ( window . Messages . strProcessingRequest ) ;
2071- $theForm . append ( '<input type="hidden" name="ajax_request" value="true">' ) ;
2074+ var submitForm = function ( ) {
2075+ var $msgbox = ajaxShowMessage ( window . Messages . strProcessingRequest ) ;
2076+ $theForm . append ( '<input type="hidden" name="ajax_request" value="true">' ) ;
20722077
2073- $ . post ( $theForm . attr ( 'action' ) , $theForm . serialize ( ) + CommonParams . get ( 'arg_separator' ) + 'change_pw=' + thisValue , function ( data ) {
2074- if ( typeof data === 'undefined' || data . success !== true ) {
2075- ajaxShowMessage ( data . error , false ) ;
2078+ $ . post ( $theForm . attr ( 'action' ) , $theForm . serialize ( ) + CommonParams . get ( 'arg_separator' ) + 'change_pw=' + thisValue , function ( data ) {
2079+ if ( typeof data === 'undefined' || data . success !== true ) {
2080+ ajaxShowMessage ( data . error , false ) ;
20762081
2077- return ;
2078- }
2082+ return ;
2083+ }
20792084
2080- var $pageContent = $ ( '#page_content' ) ;
2081- $pageContent . prepend ( data . message ) ;
2082- highlightSql ( $pageContent ) ;
2083- $ ( '#change_password_dialog' ) . hide ( ) . remove ( ) ;
2084- $ ( '#edit_user_dialog' ) . dialog ( 'close' ) . remove ( ) ;
2085- ajaxRemoveMessage ( $msgbox ) ;
2086- } ) ; // end $.post()
2085+ var $pageContent = $ ( '#page_content' ) ;
2086+ $pageContent . prepend ( data . message ) ;
2087+ highlightSql ( $pageContent ) ;
2088+ $ ( '#change_password_dialog' ) . hide ( ) . remove ( ) ;
2089+ $ ( '#edit_user_dialog' ) . dialog ( 'close' ) . remove ( ) ;
2090+ ajaxRemoveMessage ( $msgbox ) ;
2091+ } ) ; // end $.post()
2092+
2093+ $ ( '#changePasswordModal' ) . modal ( 'hide' ) ;
2094+ } ;
20872095
2088- $ ( '#changePasswordModal' ) . modal ( 'hide' ) ;
2096+ if ( shouldShowEmptyPasswordWarning ( $theForm ) ) {
2097+ $ ( this ) . confirm ( window . Messages . strPasswordEmptyWhenAllowNoPasswordIsEnabled , '' , function ( ) {
2098+ submitForm ( ) ;
2099+ } ) ;
2100+ } else {
2101+ submitForm ( ) ;
2102+ }
20892103 } ) ;
20902104
20912105 $ . get ( $ ( this ) . attr ( 'href' ) , { 'ajax_request' : true } , function ( data ) {
0 commit comments