From 5369a924a85afe4a528892e1eda7bcb5d3e6627f Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 19 Nov 2020 15:54:04 -0300 Subject: [PATCH] Bug 27060: Handle password changes more robustly This patch makes the changes in the password input trigger an event that marks the password as changed. This way we don't need to compare with the "****" string in the controller. A convenient link for restoring the original password is added with a proper description that marks the password as untouched, also restoring the "****" value. To test: 1. Apply this patch 2. Have an SMTP server set 3. Open for edition 4. In paralell, have a terminal with $ koha-mysql kohadev > SELECT * FROM smtp_servers; => SUCCESS: The password you chose is there 5. Edit the password, save => SUCCESS: The password is there 6. Edit the password, choose to reset it to the one in the DB, save => SUCCESS: The password hasn't been changed! 7. Edit the password, put ****. save => SUCCESS: The password has been updated to **** 8. Sign off :-D Signed-off-by: Tomas Cohen Arazi --- admin/smtp_servers.pl | 5 +++-- .../prog/en/modules/admin/smtp_servers.tt | 13 ++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/admin/smtp_servers.pl b/admin/smtp_servers.pl index 19458a23a42..d23f98673dd 100755 --- a/admin/smtp_servers.pl +++ b/admin/smtp_servers.pl @@ -123,10 +123,11 @@ elsif ( $op eq 'edit_save' ) { my $password = $input->param('smtp_password') || undef; my $debug = ( scalar $input->param('smtp_debug_mode') ) ? 1 : 0; + my $password_changed = $input->param('password_changed') // 'no'; + try { $smtp_server->password( $password ) - if defined $password and $password ne '****' - or not defined $password; + if $password_changed eq 'yes'; $smtp_server->set( { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt index 66975366db9..4a8f2de348b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt @@ -173,10 +173,11 @@ SMTP servers
  • [% IF smtp_server.password %] - + [% ELSE %] [% END %] +
  • @@ -271,6 +272,16 @@ SMTP servers