Avoid reporting success when API key insertion fails.

This commit is contained in:
Jeff Stieler 2021-10-07 16:06:08 -04:00 committed by Nestor Soriano
parent 68f1b12797
commit 4975a5ea21
No known key found for this signature in database
GPG Key ID: 08110F3518C12CAD
1 changed files with 4 additions and 0 deletions

View File

@ -2126,6 +2126,10 @@ class WC_AJAX {
)
);
if ( 0 === $wpdb->insert_id ) {
throw new Exception( __( 'There was an error generating your API Key.', 'woocommerce' ) );
}
$key_id = $wpdb->insert_id;
$response = $data;
$response['consumer_key'] = $consumer_key;