remove broken instructorcheck from login-controller

This commit is contained in:
regularmute
2024-04-30 19:19:04 +03:00
parent bc7fb93b67
commit 5778a64244
+1 -26
View File
@@ -10,30 +10,6 @@ const handleDatabaseError = (res, error) => {
.json({ error: 'Something is wrong... try reloading the page' })
}
const checkIfActiveInstructor = async (student_number) => {
try {
const latestConfigurationId = await db.Configuration.findOne({
order: [['created_at', 'DESC']],
attributes: ['id']
})
if (!latestConfigurationId) {
return false
}
const group = await db.Group.findOne({
where: {
configuration_id: latestConfigurationId.id,
instructor_id: student_number
}
})
return !!group
} catch (error) {
console.error('Error checking if active instructor:', error)
return false
}
}
loginRouter.post('/', async (req, res) => {
if (!req.headers.hypersonstudentid)
return res
@@ -51,8 +27,7 @@ loginRouter.post('/', async (req, res) => {
if (foundUser) {
//user already in database, no need to add
const token = jwt.sign(
{ id: foundUser.student_number, admin: foundUser.admin,
instructor: checkIfActiveInstructor(foundUser.student_number) },
{ id: foundUser.student_number, admin: foundUser.admin },
config.secret
)
return res.status(200).set('Cache-Control', 'no-store').json({