Skip to content

Commit f1bd615

Browse files
CopilotMiodec
andcommitted
Implement temporary email detection for registration
Co-authored-by: Miodec <[email protected]>
1 parent c461a4a commit f1bd615

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
"color-blend": "4.0.0",
9595
"damerau-levenshtein": "1.0.8",
9696
"date-fns": "3.6.0",
97+
"disposable-email-domains-js": "^1.0.35",
9798
"firebase": "12.0.0",
9899
"hangul-js": "0.2.6",
99100
"howler": "2.2.3",

frontend/src/ts/pages/login.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,26 @@ validateWithIndicator(nameInputEl, {
8080
},
8181
});
8282

83+
// Variable to store the disposable email module and loading state
84+
let disposableEmailModule: any = null;
85+
let moduleLoadAttempted = false;
86+
8387
const emailInputEl = document.querySelector(
8488
".page.pageLogin .register.side input.emailInput"
8589
) as HTMLInputElement;
90+
91+
// Add focus event listener to dynamically import disposable email package
92+
emailInputEl.addEventListener("focus", async () => {
93+
if (!moduleLoadAttempted) {
94+
moduleLoadAttempted = true;
95+
try {
96+
disposableEmailModule = await import("disposable-email-domains-js");
97+
} catch (e) {
98+
// Silent failure as requested - don't throw or notify user
99+
}
100+
}
101+
});
102+
86103
validateWithIndicator(emailInputEl, {
87104
schema: UserEmailSchema,
88105
isValid: async (email: string) => {
@@ -103,6 +120,20 @@ validateWithIndicator(emailInputEl, {
103120
warning: "Please check your email address, it may contain a typo.",
104121
};
105122
}
123+
124+
// Check for temporary/disposable email
125+
if (disposableEmailModule && disposableEmailModule.isDisposableEmail) {
126+
try {
127+
if (disposableEmailModule.isDisposableEmail(email)) {
128+
return {
129+
warning: "Be careful when using temporary emails - you will need it to log into your account",
130+
};
131+
}
132+
} catch (e) {
133+
// Silent failure - if the check fails, continue with validation
134+
}
135+
}
136+
106137
return true;
107138
},
108139
debounceDelay: 0,

0 commit comments

Comments
 (0)