Bug 31378: (QA follow-up) Defer store until JSON fields are populated

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Tomas Cohen Arazi 2022-11-18 12:29:55 -03:00
parent 79b93a6bdf
commit afd0bf0678
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
2 changed files with 10 additions and 10 deletions

View File

@ -107,7 +107,7 @@ sub set_config {
try {
my $encoded_config = encode_json($config);
$self->config($encoded_config)->store;
$self->config($encoded_config);
} catch {
Koha::Exceptions::Object::BadValue->throw("Error serializing data into JSON: $_");
};
@ -147,7 +147,7 @@ sub set_mapping {
try {
my $encoded_mapping = encode_json( $mapping );
$self->mapping( $encoded_mapping )->store;
$self->mapping( $encoded_mapping );
}
catch {
Koha::Exceptions::Object::BadValue->throw("Error serializing data into JSON: $_");

View File

@ -108,11 +108,10 @@ sub add {
my $class = Koha::Auth::Identity::Provider::protocol_to_class_mapping->{$protocol};
my $provider = $class->new_from_api( $body );
$provider->store;
$provider->set_config( $config );
$provider->set_mapping( $mapping );
my $provider = $class->new_from_api( $body )
->set_config( $config )
->set_mapping( $mapping )
->store;
$c->res->headers->location( $c->req->url->to_string . '/' . $provider->identity_provider_id );
return $c->render(
@ -173,9 +172,10 @@ sub update {
$provider = $provider->set_from_api( $body )->upgrade_class;
$provider->set_config( $config );
$provider->set_mapping( $mapping );
# set_config and set_mapping already called store()
$provider->set_config( $config )
->set_mapping( $mapping )
->store;
$provider->discard_changes;
return $c->render(