Skip to content

Commit

Permalink
refactor: reuse isDefaultFromAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
KishenKumarrrrr committed Sep 2, 2024
1 parent d7b4229 commit 69cf50c
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions backend/src/email/middlewares/email.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,10 @@ export const InitEmailMiddleware = (
const { fromName: defaultFromName, fromAddress: defaultFromAddress } =
parseFromAddress(config.get('mailFrom'))

// As part of a PSD directive, we have changed the defaultFromAddress to [email protected].
// To prevent any breaking changes, we must now support both the new and old default address
const allowedDefaultAddresses = [
defaultFromAddress,
'[email protected]',
]

if (
// user enters an email that is neither their own nor info@mail.postman.gov.sg
fromAddress !== userEmail &&
!allowedDefaultAddresses.includes(fromAddress)
!isDefaultFromAddress(from)
) {
logger.error({
message: INVALID_FROM_ADDRESS_ERROR_MESSAGE,
Expand Down

0 comments on commit 69cf50c

Please sign in to comment.