Skip to content

Commit

Permalink
Revalidation: Allow for the data-2fa-required element to be a <button…
Browse files Browse the repository at this point in the history
…> or other element.
  • Loading branch information
dd32 authored Dec 10, 2024
1 parent 317d352 commit 4b6ce4b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions revalidation/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ window.wp = window.wp || {};

// Does the provided URL look like a revalidation url?
const urlLooksLikeRevalidationURL = function( url ) {
return url.includes( 'wp-login.php' ) && url.includes( 'action=revalidate_2fa' );
return url && url.includes( 'wp-login.php' ) && url.includes( 'action=revalidate_2fa' );
};

// Display a modal dialog asking to revalidate.
Expand Down Expand Up @@ -159,11 +159,11 @@ window.wp = window.wp || {};
};

// Attach event listeners to all revalidate links and those that require 2FA sessions.
document.querySelectorAll( 'a[href*="action=revalidate_2fa"], a[data-2fa-required]' ).forEach(
document.querySelectorAll( 'a[href*="action=revalidate_2fa"], [data-2fa-required]' ).forEach(
(el) => el.addEventListener( 'click', maybeRevalidateOnLinkNavigate )
);

// Watch for revalidation completion.
window.addEventListener( 'message', messageHandler );

} )( wporgTwoFactorRevalidation, window.wp );
} )( wporgTwoFactorRevalidation, window.wp );

0 comments on commit 4b6ce4b

Please sign in to comment.