Skip to content
Snippets Groups Projects
Commit 8d9e462c authored by Bogdan Cochior's avatar Bogdan Cochior
Browse files

fix(mailing): catch mailing service error and fix config typo

parent 5c7a68b2
No related branches found
No related tags found
No related merge requests found
......@@ -50,15 +50,21 @@ module.exports = async (
user.assignations = []
user.assignations.push(assignation)
user = await user.save()
await mailService.setupAssignEmail(
user.email,
'assign-handling-editor',
url,
)
// TODO: create a team and add the team id to the user's teams array
try {
await mailService.setupAssignEmail(
user.email,
'assign-handling-editor',
url,
)
return res.status(200).json(user)
} catch (e) {
logger.error(e)
return res.status(500).json({ error: 'Mailing could not be sent.' })
}
return res.status(200).json(user)
// TODO: create a team and add the team id to the user's teams array
} catch (e) {
const notFoundError = await helpers.handleNotFoundError(e, 'user')
return res.status(notFoundError.status).json({
......
......@@ -27,14 +27,18 @@ module.exports = async (body, UserModel, res, url) => {
title,
UserModel,
)
try {
await mailService.setupInviteEmail(
newUser.email,
'invite',
newUser.passwordResetToken,
url,
)
await mailService.setupInviteEmail(
newUser.email,
'invite',
newUser.passwordResetToken,
url,
)
return res.status(200).json(newUser)
return res.status(200).json(newUser)
} catch (e) {
logger.error(e)
return res.status(500).json({ error: 'Mailing could not be sent.' })
}
}
}
......@@ -27,7 +27,7 @@ module.exports = {
const { htmlBody, textBody } = getEmailBody(emailType, replacements)
await Email.send(email, subject, textBody, htmlBody)
return await Email.send(email, subject, textBody, htmlBody)
},
setupAssignEmail: async (email, emailType, dashBoardUrl) => {
let subject
......@@ -46,7 +46,7 @@ module.exports = {
const { htmlBody, textBody } = getEmailBody(emailType, replacements)
Email.send(email, subject, textBody, htmlBody)
return await Email.send(email, subject, textBody, htmlBody)
},
}
......
......@@ -19,7 +19,10 @@ const onSubmit = (values, dispatch, { isEdit, history }) => {
if (!isEdit) {
const newValues = setAdmin(values)
return create('/users/invite', newValues)
.then(r => history.push('/admin/users'))
.then(r => {
console.log(r)
history.push('/admin/users')
})
.catch(error => {
const err = get(error, 'response')
if (err) {
......
......@@ -29,6 +29,9 @@ export default compose(
const Root = styled.div`
font-family: ${props => props.theme.fontInterface};
div[open] {
width: auto;
}
`
const MainContainer = styled.div`
......
......@@ -4,7 +4,7 @@ module.exports = {
from: process.env.EMAIL_SENDER,
transport: {
SES: new AWS.SES({
accessKeyId: process.env.AWS_SES_ACCESS_KEYs,
accessKeyId: process.env.AWS_SES_ACCESS_KEY,
secretAccessKey: process.env.AWS_SES_SECRET_KEY,
region: process.env.AWS_SES_REGION,
}),
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment