mirror of
https://github.com/UniversityOfHelsinkiCS/ohtuilmo.git
synced 2026-10-12 19:03:41 +03:00
remove broken instructorcheck from login-controller
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user