Skip to content

Commit 1198ebb

Browse files
committed
Show notice for re-connect incase of token decryption fail.
1 parent 19e72d1 commit 1198ebb

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

mailchimp.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,8 +1415,18 @@ function mailchimp_sf_create_nonce( $action = -1 ) {
14151415
* @return string|bool
14161416
*/
14171417
function mailchimp_sf_get_access_token() {
1418-
$access_token = get_option( 'mailchimp_sf_access_token' );
1418+
$access_token = get_option( 'mailchimp_sf_access_token' );
1419+
if ( empty( $access_token ) ) {
1420+
return false;
1421+
}
1422+
14191423
$data_encryption = new Mailchimp_Data_Encryption();
1424+
$access_token = $data_encryption->decrypt( $access_token );
1425+
1426+
// If decryption fails, display notice to user to re-authenticate.
1427+
if ( false === $access_token ) {
1428+
update_option( 'mailchimp_sf_auth_error', true );
1429+
}
14201430

1421-
return $data_encryption->decrypt( $access_token );
1431+
return $access_token;
14221432
}

0 commit comments

Comments
 (0)