Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use local free email providers #767

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
DATABASE_URL=postgres://moncomptepro:[email protected]:5432/moncomptepro
FEATURE_CONSIDER_ALL_EMAIL_DOMAINS_AS_NON_FREE=False
FEATURE_USE_ANNUAIRE_EMAILS=True
FEATURE_CHECK_EMAIL_DELIVERABILITY=True
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
- "!master"

env:
DATABASE_URL: postgres://moncomptepro:[email protected]:5432/moncomptepro
INSEE_CONSUMER_KEY: ${{ secrets.INSEE_CONSUMER_KEY }}
INSEE_CONSUMER_SECRET: ${{ secrets.INSEE_CONSUMER_SECRET }}

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// arbitrary selection of free email provider domains used in municipalities
// arbitrary selection of free email provider domains used by our users
export default [
"gmail.com",
"orange.fr",
Expand All @@ -12,5 +12,6 @@ export default [
"yahoo.com",
"live.fr",
"sfr.fr",
"9business.fr",
"laposte.fr",
];
6 changes: 3 additions & 3 deletions src/services/did-you-mean.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { run as spellCheckEmail } from "@zootools/email-spell-checker";
import gouvfrDomains from "./did-you-mean/gouvfr-domains";
import mostUsedFreeEmailDomains from "./did-you-mean/most-used-free-email-domains";
import otherGouvDomains from "./did-you-mean/other-gouv-domains";
import gouvfrDomains from "../data/gouvfr-domains";
import mostUsedFreeEmailDomains from "../data/most-used-free-email-domains";
import otherGouvDomains from "../data/other-gouv-domains";

// Display an email suggestion for most used public domains
export const getDidYouMeanSuggestion = (email: string): string => {
Expand Down
3 changes: 2 additions & 1 deletion src/services/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
FEATURE_CONSIDER_ALL_EMAIL_DOMAINS_AS_FREE,
FEATURE_CONSIDER_ALL_EMAIL_DOMAINS_AS_NON_FREE,
} from "../config/env";
import mostUsedFreeEmailDomains from "../data/most-used-free-email-domains";

export const isAFreeEmailProvider = (domain: string) => {
if (FEATURE_CONSIDER_ALL_EMAIL_DOMAINS_AS_FREE) {
Expand All @@ -15,7 +16,7 @@ export const isAFreeEmailProvider = (domain: string) => {
return false;
}

return isFree(domain);
return isFree(domain) || mostUsedFreeEmailDomains.includes(domain);
};

export const getEmailDomain = (email: string) => {
Expand Down
2 changes: 1 addition & 1 deletion src/services/security.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { customAlphabet, nanoid } from "nanoid/async";
import { parse_host } from "tld-extract";
import { MONCOMPTEPRO_HOST } from "../config/env";
import notificationMessages from "../config/notification-messages";
import dicewareWordlistFrAlt from "../data/diceware-wordlist-fr-alt";
import type { AmrValue } from "../types/express-session";
import { owaspPasswordStrengthTest } from "./owasp-password-strength-tester";
import dicewareWordlistFrAlt from "./security/diceware-wordlist-fr-alt";

// TODO compare to https://github.com/anandundavia/manage-users/blob/master/src/api/utils/security.js
export const hashPassword = async (plainPassword: string): Promise<string> => {
Expand Down
1 change: 1 addition & 0 deletions test/email.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe("usesAFreeEmailProvider", () => {
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
];

emailAddressesThatUsesFreeEmailProviders.forEach((email) => {
Expand Down