Avoid reporting success when API key insertion fails.

This commit is contained in:
Jeff Stieler 2021-10-07 16:06:08 -04:00
parent 20038828bb
commit 624f2eac4b
1 changed files with 4 additions and 0 deletions

View File

@ -2131,6 +2131,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;