Skip to content

Commit

Permalink
Add additional information about the revalidation state.
Browse files Browse the repository at this point in the history
  • Loading branch information
dd32 committed Oct 8, 2024
1 parent 28a4ba9 commit 6f947ae
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion revalidation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@
*/
function get_revalidation_status() {
$last_validated = Two_Factor_Core::is_current_user_session_two_factor();
$timeout = apply_filters( 'two_factor_revalidate_time', 15 * MINUTE_IN_SECONDS, get_current_user_id(), '' );
$timeout = apply_filters( 'two_factor_revalidate_time', 10 * MINUTE_IN_SECONDS, get_current_user_id(), 'display' );
$save_timeout = apply_filters( 'two_factor_revalidate_time', 10 * MINUTE_IN_SECONDS, get_current_user_id(), 'save' );
$expires_at = $last_validated + $timeout;
$expires_save = $last_validated + ( 2 * $save_timeout );

return [
'last_validated' => $last_validated,
'expires_at' => $expires_at,
'expires_save' => $expires_save,
'needs_revalidate' => ( ! $last_validated || $expires_at < time() ),
'can_save' => ( $expires_save > time() ),
];
}

Expand Down

0 comments on commit 6f947ae

Please sign in to comment.