fixed issue #951

parent a1506b4d
......@@ -260,7 +260,8 @@ module.exports = {
*/
create: function (req, res) {
var params = req.params.all();
var supervisor;
// Send email confirmation
function sendConfirmationMail(cb) {
......@@ -316,6 +317,8 @@ module.exports = {
if (!sup)
return res.serverError("Supervisor created but returned null");
supervisor = sup;
if (params.role === 'therapist_office' || params.role === 'tutor_office') {
sendConfirmationMail((err) => {
if (err) throw err;
......@@ -327,16 +330,17 @@ module.exports = {
.then((off) => {
// link supervisor with office
console.log("supervisor: \n" + JSON.stringify(supervisor));
console.log("supervisor: \n" + JSON.stringify(sup));
sup.id_off = off.id;
delete sup.password;
sup.save();
console.log("supervisor: \n" + JSON.stringify(supervisor));
console.log("supervisor: \n" + JSON.stringify(sup));
// set supervisor as admin in the office
off.admin = supervisor.id;
off.admin = sup.id;
off.save();
supervisor = sup;
sendConfirmationMail((err) => {
if (err) throw err;
return res.ok();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment