Bug 33104: Encrypt password
Signed-off-by: Jonathan Field <jonathan.field@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
a089e061d2
commit
5be64ffebe
3 changed files with 70 additions and 13 deletions
|
@ -122,7 +122,12 @@ sub interfaces {
|
|||
sub {
|
||||
$self->interfaces->delete;
|
||||
for my $interface (@$interfaces) {
|
||||
$self->_result->add_to_aqbookseller_interfaces($interface);
|
||||
Koha::Acquisition::Bookseller::Interface->new(
|
||||
{
|
||||
%$interface,
|
||||
vendor_id => $self->id,
|
||||
}
|
||||
)->store;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -16,6 +16,7 @@ package Koha::Acquisition::Bookseller::Interface;
|
|||
# along with Koha; if not, see <http://www.gnu.org/licenses>.
|
||||
|
||||
use Modern::Perl;
|
||||
use Koha::Encryption;
|
||||
|
||||
use base qw( Koha::Object );
|
||||
|
||||
|
@ -29,6 +30,38 @@ Koha::Acquisition::Bookseller::Interface - Koha Bookseller interface Object clas
|
|||
|
||||
=cut
|
||||
|
||||
=head3 store
|
||||
|
||||
$self->store;
|
||||
|
||||
Specific store method to encrypt the password.
|
||||
|
||||
=cut
|
||||
|
||||
sub store {
|
||||
my ($self) = @_;
|
||||
|
||||
if ( $self->password ) {
|
||||
$self->password(Koha::Encryption->new->encrypt_hex($self->password));
|
||||
}
|
||||
|
||||
return $self->SUPER::store;
|
||||
}
|
||||
|
||||
=head3 plain_text_password
|
||||
|
||||
my $plain_text_password = $self->plain_text_password;
|
||||
|
||||
Decrypt the password and return its plain text form.
|
||||
|
||||
=cut
|
||||
|
||||
sub plain_text_password {
|
||||
my ($self) = @_;
|
||||
return Koha::Encryption->new->decrypt_hex($self->password)
|
||||
if $self->password;
|
||||
}
|
||||
|
||||
=head3 _type
|
||||
|
||||
=cut
|
||||
|
|
|
@ -357,18 +357,28 @@
|
|||
<div id="supplier-interfaces" class="page-section">
|
||||
<h2>Interfaces</h2>
|
||||
|
||||
[% FOR interface IN vendor.interfaces %]
|
||||
[% FOR i IN vendor.interfaces %]
|
||||
<fieldset class="rows">
|
||||
<legend>[% interface.name | html %]</legend>
|
||||
<legend>[% i.name | html %]</legend>
|
||||
<ul>
|
||||
<li>
|
||||
<li>Type: [% interface.type | html %]</li>
|
||||
<li>URI: [% interface.uri | html %]</li>
|
||||
<li>Login: [% interface.login | html %]</li>
|
||||
<li>Password: [% interface.password | html %]</li>
|
||||
<li>Account email: [% interface.account_email | html %]</li>
|
||||
<li>Notes : [% interface.notes | html %]</li>
|
||||
</li>
|
||||
[% IF i.type %]
|
||||
<li>Type: [% i.type | html %]</li>
|
||||
[% END %]
|
||||
[% IF i.uri %]
|
||||
<li>URI: [% i.uri | html %]</li>
|
||||
[% END %]
|
||||
[% IF i.login %]
|
||||
<li>Login: [% i.login | html %]</li>
|
||||
[% END %]
|
||||
[% IF i.password %]
|
||||
<li>Password: <span class="password"><a href="#" class="show_password" data-plain-text-password="[% i.plain_text_password | html %]">Show</a></span></li>
|
||||
[% END %]
|
||||
[% IF i.account_email %]
|
||||
<li>Account email: [% i.account_email | html %]</li>
|
||||
[% END %]
|
||||
[% IF i.notes %]
|
||||
<li>Notes : [% i.notes | html %]</li>
|
||||
[% END %]
|
||||
</ul>
|
||||
</fieldset>
|
||||
[% END %]
|
||||
|
@ -528,9 +538,14 @@
|
|||
}
|
||||
|
||||
[% IF vendor %]
|
||||
let interfaces = [% To.json(vendor.interfaces.unblessed) | $raw %];
|
||||
let interfaces = [];
|
||||
[% FOR i_object IN vendor.interfaces %]
|
||||
[% SET i = i_object.unblessed %]
|
||||
[% SET i.password = i_object.plain_text_password %]
|
||||
interfaces.push([% To.json(i) | $raw %]);
|
||||
[% END %]
|
||||
[% ELSE %]
|
||||
let interfaces = [];
|
||||
let interfaces = [];
|
||||
[% END %]
|
||||
function serialize_interface_form(){
|
||||
interfaces = [];
|
||||
|
@ -635,6 +650,10 @@
|
|||
$(this).next('.contact_claimissues_hidden').val($(this).is(':checked') ? '1' : '0');
|
||||
});
|
||||
|
||||
$('body').on('click', '.show_password', null, function(e){
|
||||
e.preventDefault();
|
||||
$(this).parent().replaceWith($(this).data('plain-text-password'));
|
||||
});
|
||||
refresh_aliases();
|
||||
refresh_interfaces();
|
||||
|
||||
|
|
Loading…
Reference in a new issue