generated from BloomTech-Labs/labs-api-node-starter
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9119e9
commit bcf8484
Showing
5 changed files
with
24 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,5 +40,3 @@ jspm_packages/ | |
.env.test | ||
.env.local | ||
sendgrid.env | ||
sendgrid.env | ||
sendgrid.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,8 @@ const newStudent = { | |
name: 'New Student Here', | ||
}, | ||
to: '[email protected]', | ||
from: '[email protected]', // verified sender in SendGrid account | ||
// The from email must be the email address of a verified sender in SendGrid account. If/when you verify the domain, an email coming from the domain is likely good enough. | ||
from: '[email protected]', | ||
template_id: 'd-a6dacc6241f9484a96554a13bbdcd971', | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,76 +198,76 @@ router.post('/', checkProfileObject, async (req, res) => { | |
if (profileExists) { | ||
res.status(400).json({ message: 'profile already exists' }); | ||
} else { | ||
const prof = await Profiles.create(profile); | ||
if (!prof) { | ||
const newProfile = await Profiles.create(profile); | ||
if (!newProfile) { | ||
res.status(404).json({ | ||
message: 'There was an error saving the profile to the database.', | ||
}); | ||
} | ||
if (prof[0].role_id === 3 || prof[0].role_id === '3') { | ||
if (newProfile[0].role_id === 3 || newProfile[0].role_id === '3') { | ||
const instructorWelcomeMessage = { | ||
dynamic_template_data: { | ||
name: prof[0].name, | ||
name: newProfile[0].name, | ||
}, | ||
to: prof[0].email, | ||
to: newProfile[0].email, | ||
from: '[email protected]', // verified sender in SendGrid account. Try to put this in env - hardcoded here because it wasn't working there. | ||
template_id: 'd-a4de80911362438bb35d481efa068398', | ||
}; | ||
const instructorList = { | ||
list_ids: ['e7b598d9-23ca-48df-a62b-53470b5d1d86'], | ||
email: prof[0].email, | ||
name: prof[0].name, | ||
email: newProfile[0].email, | ||
name: newProfile[0].name, | ||
}; | ||
sendEmail(instructorWelcomeMessage); | ||
addToList(instructorList); | ||
res.status(200).json({ | ||
message: 'instructor profile created', | ||
profile: prof[0], | ||
profile: newProfile[0], | ||
}); | ||
} else if (prof[0].role_id === 4 || prof[0].role_id === '4') { | ||
} else if (newProfile[0].role_id === 4 || newProfile[0].role_id === '4') { | ||
const parentWelcomeMessage = { | ||
dynamic_template_data: { | ||
name: prof[0].name, | ||
name: newProfile[0].name, | ||
}, | ||
to: prof[0].email, | ||
to: newProfile[0].email, | ||
from: '[email protected]', | ||
template_id: 'd-19b895416ae74cea97e285c4401fcc1f', | ||
}; | ||
const parentList = { | ||
list: 'e7b598d9-23ca-48df-a62b-53470b5d1d86', | ||
email: prof[0].email, | ||
name: prof[0].name, | ||
email: newProfile[0].email, | ||
name: newProfile[0].name, | ||
}; | ||
sendEmail(parentWelcomeMessage); | ||
addToList(parentList); | ||
res.status(200).json({ | ||
message: 'parent profile created', | ||
profile: prof[0], | ||
profile: newProfile[0], | ||
}); | ||
} else if (prof[0].role_id === 5 || prof[0].role_id === '5') { | ||
} else if (newProfile[0].role_id === 5 || newProfile[0].role_id === '5') { | ||
const studentWelcomeMessage = { | ||
dynamic_template_data: { | ||
name: prof[0].name, | ||
name: newProfile[0].name, | ||
}, | ||
to: prof[0].email, | ||
to: newProfile[0].email, | ||
from: '[email protected]', | ||
template_id: 'd-a6dacc6241f9484a96554a13bbdcd971', | ||
}; | ||
const studentList = { | ||
list: '4dd72555-266f-4f8e-b595-ecc1f7ff8f28', | ||
email: prof[0].email, | ||
name: prof[0].name, | ||
email: newProfile[0].email, | ||
name: newProfile[0].name, | ||
}; | ||
sendEmail(studentWelcomeMessage); | ||
addToList(studentList); | ||
res.status(200).json({ | ||
message: 'parent profile created', | ||
profile: prof[0], | ||
profile: newProfile[0], | ||
}); | ||
} else { | ||
res.status(200).json({ | ||
message: 'profile created', | ||
profile: prof[0], | ||
profile: newProfile[0], | ||
}); | ||
} | ||
} | ||
|