diff --git a/config/passport.js b/config/passport.js index 42cc58c..3ca02f4 100644 --- a/config/passport.js +++ b/config/passport.js @@ -45,7 +45,7 @@ passport.use( // If the user is a parent, query the parent's students // and store the students' UPNs in the session else if (user_type === directory.USER_TYPE.PARENT) { - let students = await directory.listStudents(username); + let students = await directory.getStudentsByParent(username); profile["students"] = students; } else { console.log("Unknown user type"); diff --git a/directory.js b/directory.js index 3e886e3..532ec95 100644 --- a/directory.js +++ b/directory.js @@ -105,7 +105,7 @@ async function getPrimaryParent(student_upn) { } } -async function listStudents(upn) { +async function getStudentsByParent(upn) { // Search for students with the parent's UPN in their primaryParent attribute let opts = { filter: `(primaryParent=${upn})`, @@ -136,7 +136,7 @@ module.exports = { getUserType: getUserType, getUserTypeFromDN: getUserTypeFromDN, setPrimaryParent: setPrimaryParent, - listStudents: listStudents, + getStudentsByParent: getStudentsByParent, getPrimaryParent: getPrimaryParent, USER_TYPE: USER_TYPE }; \ No newline at end of file diff --git a/routes/ps_relation_parent.js b/routes/ps_relation_parent.js index c2d377f..a22a171 100644 --- a/routes/ps_relation_parent.js +++ b/routes/ps_relation_parent.js @@ -97,6 +97,9 @@ router.get('/parent/:parent_upn', async function (req, res) { allowedAttributes.forEach(function (attribute) { parent[attribute] = req.user[attribute]; }); + // Get the list of students linked to the parent + let students = await directory.getStudentsByParent(parent.username); + parent.students = students; res.json(parent); }); diff --git a/routes/ps_relation_student.js b/routes/ps_relation_student.js index 22ed922..7353ba0 100644 --- a/routes/ps_relation_student.js +++ b/routes/ps_relation_student.js @@ -64,6 +64,8 @@ router.get('/student/:upn', function (req, res) { allowedAttributes.forEach(function (attribute) { student[attribute] = req.user[attribute]; }); + // Return the student's linked parent in the response in JSON format + student['primary_parent'] = req.user['primaryParent']; res.json(student); }); diff --git a/statics/selfservice/parent.html b/statics/selfservice/parent.html new file mode 100644 index 0000000..34b50f3 --- /dev/null +++ b/statics/selfservice/parent.html @@ -0,0 +1,152 @@ + + + + +
+ + + + + \ No newline at end of file diff --git a/statics/selfservice/student.html b/statics/selfservice/student.html index 263662a..43989aa 100644 --- a/statics/selfservice/student.html +++ b/statics/selfservice/student.html @@ -50,45 +50,77 @@ } -