Skip to content

Commit 39ecdd4

Browse files
Make isAgentEmail case-insensitive
Add the `i` flag to AGENT_EMAIL_REGEX so inputs like AGENT_123@EXPENSIFY.AI are also blocked. Add a test case for mixed-case agent emails. Co-authored-by: Nicolás Bonet <NicolasBonet@users.noreply.github.com>
1 parent 4394aa1 commit 39ecdd4

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/libs/SessionUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function checkIfShouldUseNewPartnerName(partnerUserID?: string): boolean {
108108
return false;
109109
}
110110

111-
const AGENT_EMAIL_REGEX = /^agent_\d+@expensify\.ai$/;
111+
const AGENT_EMAIL_REGEX = /^agent_\d+@expensify\.ai$/i;
112112

113113
function isAgentEmail(email?: string): boolean {
114114
if (!email) {

tests/ui/BaseLoginFormTest.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,21 @@ describe('BaseLoginForm', () => {
104104
expect(mockBeginSignIn).not.toHaveBeenCalled();
105105
});
106106

107+
it('blocks agent email regardless of case', async () => {
108+
renderForm();
109+
110+
const input = screen.getByTestId('username');
111+
fireEvent.changeText(input, 'AGENT_123@EXPENSIFY.AI');
112+
113+
const continueButton = screen.getByText('Continue');
114+
fireEvent.press(continueButton);
115+
116+
await waitFor(() => {
117+
expect(screen.getByText(AGENT_ERROR)).toBeTruthy();
118+
});
119+
expect(mockBeginSignIn).not.toHaveBeenCalled();
120+
});
121+
107122
it('proceeds with sign-in for a normal email', async () => {
108123
renderForm();
109124

0 commit comments

Comments
 (0)