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

Proposal to allow user to OTP if mailing fails in development #62

Merged
merged 1 commit into from
May 5, 2020
Merged
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
14 changes: 9 additions & 5 deletions src/server/api/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ function isValidGovEmail(email: string) {
*/
router.get('/message', (_, res: Express.Response) => res.send(loginMessage))

router.get(
'/emaildomains',
(_, res: Express.Response) => res.send(validEmailDomainGlobExpression),
)
router.get('/emaildomains', (_, res: Express.Response) => res.send(validEmailDomainGlobExpression))

/**
* Request for an OTP to be generated.
Expand Down Expand Up @@ -73,6 +70,13 @@ router.post('/otp', (req: Express.Request, res: Express.Response) => {
mailOTP(email, otp, (mailError: Error) => {
if (!mailError) {
res.ok(jsonMessage('OTP generated and sent.'))
} else if (process.env.NODE_ENV === 'development') {
logger.warn('Allowing user to OTP even though mail errored.')
logger.warn(
'This may be an issue with your IP. More information can be found at https://support.google.com/mail/answer/10336?hl=en)',
)
logger.warn('This message should NEVER be seen in production.')
res.ok(jsonMessage('Error mailing OTP.'))
} else {
res.serverError(
jsonMessage('Error mailing OTP, please try again later.'),
Expand All @@ -84,7 +88,7 @@ router.post('/otp', (req: Express.Request, res: Express.Response) => {
})
} else {
res.badRequest(
jsonMessage('Invalid email provided. Email domain is not whitelisted.')
jsonMessage('Invalid email provided. Email domain is not whitelisted.'),
)
}
})
Expand Down