v1.0.1
This commit is contained in:
parent
212d64abfa
commit
b8e17df2db
17 changed files with 1145 additions and 732 deletions
|
|
@ -50,9 +50,9 @@ class Two_Factor_Extended_Bulk_Actions {
|
|||
*
|
||||
* @since 0.1.0
|
||||
*
|
||||
* @param array $actions Existing bulk actions.
|
||||
* @param array<string, string> $actions Existing bulk actions.
|
||||
*
|
||||
* @return array Modified bulk actions.
|
||||
* @return array<string, string> Modified bulk actions.
|
||||
*/
|
||||
public function register_bulk_actions( array $actions ): array {
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
|
|
@ -72,7 +72,7 @@ class Two_Factor_Extended_Bulk_Actions {
|
|||
*
|
||||
* @param string $redirect_to Redirect URL.
|
||||
* @param string $action Action name.
|
||||
* @param array $user_ids User IDs.
|
||||
* @param int[] $user_ids User IDs.
|
||||
*
|
||||
* @return string Modified redirect URL.
|
||||
*/
|
||||
|
|
@ -111,14 +111,18 @@ class Two_Factor_Extended_Bulk_Actions {
|
|||
*
|
||||
* @since 0.1.0
|
||||
*
|
||||
* @param array $user_ids User IDs.
|
||||
* @param int[] $user_ids User IDs.
|
||||
*
|
||||
* @return int Number of users processed.
|
||||
*/
|
||||
private function bulk_require_2fa( array $user_ids ): int {
|
||||
$processed = 0;
|
||||
$processed = 0;
|
||||
$enforcement = two_factor_extended()->get_enforcement();
|
||||
|
||||
if ( null === $enforcement ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
foreach ( $user_ids as $user_id ) {
|
||||
// Skip if user doesn't exist.
|
||||
$user = get_userdata( $user_id );
|
||||
|
|
@ -138,17 +142,21 @@ class Two_Factor_Extended_Bulk_Actions {
|
|||
update_user_meta( $user_id, Two_Factor_Extended_Enforcement::META_ENFORCEMENT_START, time() );
|
||||
|
||||
// Log the action.
|
||||
two_factor_extended()->get_audit_log()->log_event(
|
||||
'bulk_require_2fa',
|
||||
sprintf(
|
||||
'Bulk action: Require 2FA for user %s',
|
||||
$user->user_login
|
||||
),
|
||||
$user_id,
|
||||
array(
|
||||
'required_providers' => $required,
|
||||
)
|
||||
);
|
||||
$audit_log = two_factor_extended()->get_audit_log();
|
||||
|
||||
if ( null !== $audit_log ) {
|
||||
$audit_log->log_event(
|
||||
'bulk_require_2fa',
|
||||
sprintf(
|
||||
'Bulk action: Require 2FA for user %s',
|
||||
$user->user_login
|
||||
),
|
||||
$user_id,
|
||||
array(
|
||||
'required_providers' => $required,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$processed++;
|
||||
}
|
||||
|
|
@ -161,7 +169,7 @@ class Two_Factor_Extended_Bulk_Actions {
|
|||
*
|
||||
* @since 0.1.0
|
||||
*
|
||||
* @param array $user_ids User IDs.
|
||||
* @param int[] $user_ids User IDs.
|
||||
*
|
||||
* @return int Number of users processed.
|
||||
*/
|
||||
|
|
@ -182,14 +190,18 @@ class Two_Factor_Extended_Bulk_Actions {
|
|||
delete_user_meta( $user_id, Two_Factor_Extended_Enforcement::META_GRACE_NOTIFIED );
|
||||
|
||||
// Log the action.
|
||||
two_factor_extended()->get_audit_log()->log_event(
|
||||
'bulk_reset_grace',
|
||||
sprintf(
|
||||
'Bulk action: Reset grace period for user %s',
|
||||
$user->user_login
|
||||
),
|
||||
$user_id
|
||||
);
|
||||
$audit_log = two_factor_extended()->get_audit_log();
|
||||
|
||||
if ( null !== $audit_log ) {
|
||||
$audit_log->log_event(
|
||||
'bulk_reset_grace',
|
||||
sprintf(
|
||||
'Bulk action: Reset grace period for user %s',
|
||||
$user->user_login
|
||||
),
|
||||
$user_id
|
||||
);
|
||||
}
|
||||
|
||||
$processed++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue