diff --git a/includes/Core/Authentication/Authentication.php b/includes/Core/Authentication/Authentication.php index 69af086b102..65177bbe558 100644 --- a/includes/Core/Authentication/Authentication.php +++ b/includes/Core/Authentication/Authentication.php @@ -1144,24 +1144,49 @@ private function get_reauthentication_needed_notice() { ?>

{ + if ( storage ) { + for ( let i = 0; i < storage.length; i++ ) { + var itemKey = storage.key( i ); + if ( itemKey.match( 'googlesitekit_%1\$s_.*_module_setup' ) ) { + moduleSlug = JSON.parse( storage.getItem( itemKey ) )?.value; + } + } + } + }); + if ( moduleSlug ) { + var redirect = '%3\$s&slug=' + moduleSlug; + document.location = '%2\$s&redirect=' + encodeURIComponent(redirect); + } else { + if ( localStorage ) { + localStorage.clear(); + } + if ( sessionStorage ) { + sessionStorage.clear(); + } + document.location = '%2\$s'; } - if ( sessionStorage ) { - sessionStorage.clear(); - } - document.location = '%s'; } ", - esc_url_raw( $this->get_connect_url() ) + GOOGLESITEKIT_VERSION, + esc_url_raw( $this->get_connect_url() ), + esc_url_raw( + $this->context->admin_url( + 'dashboard', + array( + 'reAuth' => 'true', + ) + ) + ) ) ); return ob_get_clean();