diff --git a/changes/31343-blank-email-on-failed-login-activity b/changes/31343-blank-email-on-failed-login-activity
new file mode 100644
index 0000000000..611c148273
--- /dev/null
+++ b/changes/31343-blank-email-on-failed-login-activity
@@ -0,0 +1 @@
+* Fixed the message rendered from user_failed_login global activities on the Activity feed if the email is not specified.
\ No newline at end of file
diff --git a/frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tests.tsx b/frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tests.tsx
index 8cd14195d0..7f60d7d3ea 100644
--- a/frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tests.tsx
+++ b/frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tests.tsx
@@ -276,7 +276,21 @@ describe("Activity Feed", () => {
})
).toBeInTheDocument();
expect(
- screen.getByText("foo@example.com", { exact: false })
+ screen.getByText("foo@example.com", {
+ exact: false,
+ })
+ ).toBeInTheDocument();
+ });
+
+ it("renders a user_failed_login without an email", () => {
+ const activity = createMockActivity({
+ type: ActivityType.UserFailedLogin,
+ details: { email: "", public_ip: "192.168.0.1" },
+ });
+ render();
+
+ expect(
+ screen.getByText("Somebody failed", { exact: false })
).toBeInTheDocument();
});
diff --git a/frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsx b/frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsx
index 8d520fd924..15f5b7acb9 100644
--- a/frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsx
+++ b/frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsx
@@ -173,10 +173,19 @@ const TAGGED_TEMPLATES = {
);
},
userFailedLogin: (activity: IActivity) => {
+ const { email, public_ip } = activity.details || {};
+
+ const actor = email ? (
+ <>
+ Somebody using {email}
+ >
+ ) : (
+ <>Somebody>
+ );
+
return (
<>
- Somebody using {activity.details?.email} failed to log in from
- public IP {activity.details?.public_ip}.
+ {actor} failed to log in from public IP {public_ip}.
>
);
},