working ish website

This commit is contained in:
Siwat Sirichai 2024-05-05 18:13:58 +07:00
parent 5540ac6d81
commit b194d2031d
8 changed files with 271 additions and 6 deletions

View file

@ -3,6 +3,7 @@
let express = require('express');
let router = express.Router();
let passport = require('passport');
let directory = require('../directory.js');
let database = require('../config/database.js');
let uuid = require('uuid');
@ -24,6 +25,9 @@ router.get('/student/:upn/pairing-code', function (req, res) {
if(!req.isAuthenticated()) {
return res.status(401).send('Unauthorized');
}
if (req.user.userType !== directory.USER_TYPE.STUDENT) {
return res.status(403).send('Forbidden, not a student');
}
let upn = req.params.upn;
// Is the logged in user a student with the same UPN as the one in the URL?
// If not, return a 403 Forbidden response
@ -45,6 +49,9 @@ router.get('/student/:upn', function (req, res) {
if(!req.isAuthenticated()) {
return res.status(401).send('Unauthorized');
}
if (req.user.userType !== directory.USER_TYPE.STUDENT) {
return res.status(403).send('Forbidden, not a student');
}
let upn = req.params.upn;
// Is the logged in user a student with the same UPN as the one in the URL?
// If not, return a 403 Forbidden response