Skip to content

Commit

Permalink
Protect card: Add the number of Logins Blocked. (#38396)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottprogrammer authored Jul 19, 2024
1 parent 28e5ed3 commit 027dc55
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,19 @@ const ValueSection: FC< {
<div className="value-section__logins-blocked">
<div className="value-section__heading">Logins Blocked</div>
<div className="value-section__data">
<div className="logins_blocked__count">0</div>
<LoginsBlockedStatus />
</div>
</div>
</div>
</>
);
};

const LoginsBlockedStatus = () => {
const {
protect: { wafConfig: wafData },
} = getMyJetpackWindowInitialState();
const { blocked_logins: blockedLoginsCount = 0 } = wafData || {};

return <div className="logins_blocked__count">{ blockedLoginsCount }</div>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: added

Add the number of logins blocked to the Protect card in My Jetpack.
1 change: 1 addition & 0 deletions projects/packages/my-jetpack/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ interface Window {
};
wafConfig: {
automatic_rules_available: boolean;
blocked_logins: number;
bootstrap_path: string;
brute_force_protection: boolean;
jetpack_waf_automatic_rules: '1' | '';
Expand Down
5 changes: 4 additions & 1 deletion projects/packages/my-jetpack/src/class-initializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ public static function enqueue_scripts() {
'latestBoostSpeedScores' => $latest_score,
'protect' => array(
'scanData' => $scan_data,
'wafConfig' => Waf_Runner::get_config(),
'wafConfig' => array_merge(
Waf_Runner::get_config(),
array( 'blocked_logins' => (int) get_site_option( 'jetpack_protect_blocked_attempts', 0 ) )
),
),
)
);
Expand Down

0 comments on commit 027dc55

Please sign in to comment.