Bug 28912: Prevent Pseudonymization to be set if bcrypt_settings not set
If Pseudonymization is set but the bcrypt_settings config used by the feature is not set, then there is an ugly 500 on checking out. bad bcrypt settings at /kohadevbox/koha/Koha/PseudonymizedTransaction.pm line 116. However it's pretty hard to handle correctly this exception (and that's why it hasn't be done initially). However we could prevent the pref to be turned on if the config entry is not present. Test plan: Remove the bcrypt_settings from the config Try to turn the syspref on Add the config Try to turn the syspref on/off Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> JD amended patch: fix qa failures Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
60873e6030
commit
f73868b8ee
2 changed files with 22 additions and 2 deletions
|
@ -184,6 +184,7 @@ sub TransformPrefsToHTML {
|
|||
foreach my $line ( @{ $tab->{ $group } } ) {
|
||||
my @chunks;
|
||||
my @names;
|
||||
my @warnings;
|
||||
|
||||
foreach my $piece ( @$line ) {
|
||||
if ( ref ( $piece ) eq 'HASH' ) {
|
||||
|
@ -202,6 +203,10 @@ sub TransformPrefsToHTML {
|
|||
# No highlighting of inputs yet, but would be useful
|
||||
$chunk->{'highlighted'} = 1 if ( $searchfield && $name =~ /^$searchfield$/i );
|
||||
|
||||
if ( $name eq 'Pseudonymization' && ! C4::Context->config('bcrypt_settings')) {
|
||||
push @warnings, 'bcrypt_config_not_set';
|
||||
$chunk->{disabled} = 1 unless $value; # Let disable if enabled
|
||||
}
|
||||
push @chunks, $chunk;
|
||||
|
||||
my $name_entry = { name => $name };
|
||||
|
@ -213,6 +218,7 @@ sub TransformPrefsToHTML {
|
|||
}
|
||||
}
|
||||
$name_entry->{'overridden'} = 1 if ( any { $name eq $_ } @override_syspref_names );
|
||||
|
||||
push @names, $name_entry;
|
||||
} else {
|
||||
push @chunks, $piece;
|
||||
|
@ -230,7 +236,7 @@ sub TransformPrefsToHTML {
|
|||
push @chunks, { type_text => 1, contents => $piece };
|
||||
}
|
||||
}
|
||||
push @lines, { CHUNKS => \@chunks, NAMES => \@names, is_group_title => 0 };
|
||||
push @lines, { CHUNKS => \@chunks, NAMES => \@names, WARNINGS => \@warnings, is_group_title => 0 };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,11 @@
|
|||
<input type="[%IF CHUNK.input_type %][% CHUNK.input_type | html %][% ELSE %]text[% END %]" name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]" class="preference preference-[% CHUNK.class or "short" | html %]" value="[% CHUNK.value | html %]" autocomplete="off" /> [% IF ( CHUNK.dateinput ) %]<span class="hint">[% INCLUDE 'date-format.inc' %]</span>[% END %]
|
||||
[% END %]
|
||||
[% ELSIF ( CHUNK.type_select ) %]
|
||||
[% IF CHUNK.disabled %]
|
||||
<select name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]" disabled="disabled" class="preference preference-[% CHUNK.class or "choice" | html %]">
|
||||
[% ELSE %]
|
||||
<select name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]" class="preference preference-[% CHUNK.class or "choice" | html %]">
|
||||
[% END %]
|
||||
[% FOREACH CHOICE IN CHUNK.CHOICES.sort('value') %]
|
||||
[% IF ( CHOICE.selected ) %]
|
||||
<option value="[% CHOICE.value | html %]" selected="selected">
|
||||
|
@ -178,6 +182,16 @@
|
|||
</ul> <!-- / ul.sortable -->
|
||||
[% END %]
|
||||
[% END %]
|
||||
[% IF LINE.WARNINGS.size %]
|
||||
[% FOR w IN LINE.WARNINGS %]
|
||||
<div class="dialog alert">
|
||||
[% SWITCH w %]
|
||||
[% CASE "bcrypt_config_not_set" %]Pseudonymization must only be turned on if the 'bcrypt_settings' configuration entry exists and is correctly filled in the Koha configuration file.
|
||||
[% CASE %]Unknown warning "[% w | html %]"
|
||||
[% END %]
|
||||
</div>
|
||||
[% END %]
|
||||
[% END %]
|
||||
</div></td>
|
||||
</tr>
|
||||
[% IF ( loop.last ) %]</tbody></table>[% END %]
|
||||
|
|
Loading…
Reference in a new issue