Skip to content

Commit

Permalink
feat: add 9business to free email provider + use local free email dom…
Browse files Browse the repository at this point in the history
…ain list in 2 services
  • Loading branch information
rdubigny committed Oct 16, 2024
1 parent 3665a8c commit a38cf37
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 6 deletions.
File renamed without changes.
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",
];
File renamed without changes.
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

0 comments on commit a38cf37

Please sign in to comment.