Skip to content
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
17 changes: 0 additions & 17 deletions src/connectors/brevo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,13 @@ const remoteTemplateSlugToBrevoTemplateId: {
"join-organization": 4,
"verify-email": 6,
};
const localTemplateSlugs: LocalTemplateSlug[] = [
"organization-welcome",
"unable-to-auto-join-organization",
"welcome",
"moderation-processed",
"delete-account",
"delete-free-totp",
"delete-access-key",
"add-access-key",
"update-totp-application",
"add-2fa",
"update-personal-data",
];
const defaultBrevoTemplateId = 7;

const hasRemoteTemplate = (
template: RemoteTemplateSlug | LocalTemplateSlug,
): template is RemoteTemplateSlug =>
remoteTemplateSlugToBrevoTemplateId.hasOwnProperty(template);

const isLocalTemplateSlug = (value: string): value is LocalTemplateSlug => {
return localTemplateSlugs.includes(value as LocalTemplateSlug);
};

export const sendMail = async ({
to = [],
cc = [],
Expand Down
11 changes: 4 additions & 7 deletions src/controllers/user/verify-email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@ export const getVerifyEmailController = async (

const { new_code_sent } = await schema.parseAsync(req.query);

const {
id: user_id,
email,
needs_inclusionconnect_onboarding_help,
} = getUserFromAuthenticatedSession(req);
const { email, needs_inclusionconnect_onboarding_help } =
getUserFromAuthenticatedSession(req);

const codeSent: boolean = await sendEmailAddressVerificationEmail({
email,
Expand Down Expand Up @@ -75,7 +72,7 @@ export const postVerifyEmailController = async (

const { verify_email_token } = await schema.parseAsync(req.body);

const { id: user_id, email } = getUserFromAuthenticatedSession(req);
const { email } = getUserFromAuthenticatedSession(req);

const updatedUser = await verifyEmail(email, verify_email_token);

Expand Down Expand Up @@ -104,7 +101,7 @@ export const postSendEmailVerificationController = async (
next: NextFunction,
) => {
try {
const { id: user_id, email } = getUserFromAuthenticatedSession(req);
const { email } = getUserFromAuthenticatedSession(req);

await sendEmailAddressVerificationEmail({
email,
Expand Down
5 changes: 2 additions & 3 deletions src/middlewares/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ export const checkUserIsVerifiedMiddleware = (
try {
if (error) return next(error);

const { id, email, email_verified } =
getUserFromAuthenticatedSession(req);
const { email, email_verified } = getUserFromAuthenticatedSession(req);

const needs_email_verification_renewal =
await needsEmailVerificationRenewal(email);
Expand Down Expand Up @@ -238,7 +237,7 @@ export const checkUserHasPersonalInformationsMiddleware = (
try {
if (error) return next(error);

const { given_name, family_name, phone_number, job } =
const { given_name, family_name, job } =
getUserFromAuthenticatedSession(req);
if (isEmpty(given_name) || isEmpty(family_name) || isEmpty(job)) {
return res.redirect("/users/personal-information");
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"module": "Preserve",
"moduleResolution": "Bundler",
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"outDir": "./build",
"resolveJsonModule": true,
"rootDir": "./src"
Expand Down