Bug 28772: DBRev 20.05.15.001

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
This commit is contained in:
Victor Grousset/tuxayo 2021-09-20 08:44:59 +02:00
parent d5338cc9c0
commit e504ad8bc1
3 changed files with 31 additions and 30 deletions

View File

@ -29,7 +29,7 @@ use vars qw{ $VERSION };
# - #4 : the developer version. The 4th number is the database subversion.
# used by developers when the database changes. updatedatabase take care of the changes itself
# and is automatically called by Auth.pm when needed.
$VERSION = "20.05.15.000";
$VERSION = "20.05.15.001";
sub version {
return $VERSION;

View File

@ -1,29 +0,0 @@
$DBversion = 'XXX';
if( CheckVersion( $DBversion ) ) {
use Koha::AuthUtils qw(hash_password);
my $sth = $dbh->prepare(q{
SELECT client_id, secret
FROM api_keys
});
$sth->execute;
my $results = $sth->fetchall_arrayref({});
$sth = $dbh->prepare(q{
UPDATE api_keys
SET
secret = ?
WHERE
client_id = ?
});
foreach my $api_key (@$results) {
unless ( $api_key->{secret} =~ m/^\$2a\$08\$/ ) {
my $digest = Koha::AuthUtils::hash_password( $api_key->{secret} );
$sth->execute( $digest, $api_key->{client_id} );
}
}
NewVersion( $DBversion, 28772, "Store hashed API key secrets" );
}

View File

@ -22678,6 +22678,36 @@ if( CheckVersion( $DBversion ) ) {
NewVersion( $DBversion, "", "Koha 20.05.15 release" );
}
$DBversion = '20.05.15.001';
if ( CheckVersion( $DBversion ) ) {
use Koha::AuthUtils qw(hash_password);
my $sth = $dbh->prepare(q{
SELECT client_id, secret
FROM api_keys
});
$sth->execute;
my $results = $sth->fetchall_arrayref({});
$sth = $dbh->prepare(q{
UPDATE api_keys
SET
secret = ?
WHERE
client_id = ?
});
foreach my $api_key (@$results) {
unless ( $api_key->{secret} =~ m/^\$2a\$08\$/ ) {
my $digest = Koha::AuthUtils::hash_password( $api_key->{secret} );
$sth->execute( $digest, $api_key->{client_id} );
}
}
NewVersion( $DBversion, 28772, "Store hashed API key secrets" );
}
# SEE bug 13068
# if there is anything in the atomicupdate, read and execute it.
my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/';