Skip to content

Commit 87477a1

Browse files
authored
fix: Prevent email enumeration for password recovery (#2925)
* fix: Prevent email enumeration for password recovery * feedback
1 parent 93969d8 commit 87477a1

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

src/routes/(public)/recover/+page.svelte

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,31 @@
2323
});
2424
2525
async function recover() {
26+
let showGenericSuccessNotification = true;
2627
try {
2728
await sdk.forConsole.account.createRecovery({
2829
email,
2930
url: window.location.toString()
3031
});
31-
addNotification({
32-
type: 'success',
33-
message: 'We have sent you an email with a password reset link'
34-
});
3532
trackEvent(Submit.AccountRecover);
3633
} catch (error) {
34+
// Do not show error for 403 Forbidden or 404 Not Found to prevent email enumeration
35+
if (error.code !== 403 && error.code !== 404) {
36+
showGenericSuccessNotification = false;
37+
addNotification({
38+
type: 'error',
39+
message: error.message
40+
});
41+
trackError(error, Submit.AccountRecover);
42+
}
43+
}
44+
45+
if (showGenericSuccessNotification) {
3746
addNotification({
38-
type: 'error',
39-
message: error.message
47+
type: 'success',
48+
message:
49+
'If an account exists for this email, you will receive a password reset link shortly'
4050
});
41-
trackError(error, Submit.AccountRecover);
4251
}
4352
}
4453

0 commit comments

Comments
 (0)