Use proper prefix for user_failed_login activity (#32092)

For #31343

Fixed the message rendered from user_failed_login global activities on
the Activity feed if the email is not specified.
This commit is contained in:
Juan Fernandez
2025-08-20 17:39:57 -04:00
committed by GitHub
parent 41fd8409e9
commit 66f255e4eb
3 changed files with 27 additions and 3 deletions
@@ -0,0 +1 @@
* Fixed the message rendered from user_failed_login global activities on the Activity feed if the email is not specified.
@@ -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(<GlobalActivityItem activity={activity} isPremiumTier />);
expect(
screen.getByText("Somebody failed", { exact: false })
).toBeInTheDocument();
});
@@ -173,10 +173,19 @@ const TAGGED_TEMPLATES = {
);
},
userFailedLogin: (activity: IActivity) => {
const { email, public_ip } = activity.details || {};
const actor = email ? (
<>
Somebody using <b>{email}</b>
</>
) : (
<>Somebody</>
);
return (
<>
Somebody using <b>{activity.details?.email}</b> failed to log in from
public IP {activity.details?.public_ip}.
{actor} failed to log in from public IP {public_ip}.
</>
);
},