From 6e87fa9bb003c6358424a18e1072ea9e520a725f Mon Sep 17 00:00:00 2001 From: Matti Luukkainen Date: Fri, 26 Jan 2024 22:45:22 +0200 Subject: [PATCH] debug --- server/middleware/authenticationMiddleware.js | 2 + server/models/lib/mock.js | 70 ++++++++++--------- server/models/user.js | 5 +- 3 files changed, 44 insertions(+), 33 deletions(-) diff --git a/server/middleware/authenticationMiddleware.js b/server/middleware/authenticationMiddleware.js index 7fc51a2..cc87091 100644 --- a/server/middleware/authenticationMiddleware.js +++ b/server/middleware/authenticationMiddleware.js @@ -30,6 +30,7 @@ const authentication = async (req, res, next) => { } console.log('hygroupcn', hygroupcn) + console.log('username', uid) req.toska = hygroupcn && hygroupcn.includes('grp-toska') const foundUser = await User.findOne({ @@ -131,6 +132,7 @@ const authentication = async (req, res, next) => { } return next() } catch (e) { + console.log('-->', e) logger.error(['Creating student failed', e.toString(), e.response ? e.response.data : null]) Sentry.withScope(() => { Sentry.captureMessage('Creating student failed!') diff --git a/server/models/lib/mock.js b/server/models/lib/mock.js index 30a88cb..e3973f2 100644 --- a/server/models/lib/mock.js +++ b/server/models/lib/mock.js @@ -21,6 +21,7 @@ const mockData = { admission_date: '2017-06-30T21:00:00.000Z', end_date: '2024-07-30T21:00:00.000Z', start_date: '2017-07-31T21:00:00.000Z', + id: 'hy-opinoik-131106475', }, ], }, @@ -28,22 +29,24 @@ const mockData = { md5: '12345', status: 200, elapsed: 0.002677027, - data: [ - { - full_time_student: 'true', - semester_enrollment_type_code: 1, - absence_reason_code: null, - semester_enrollment_date: '2016-06-30T21:00:00.000Z', - semester_code: 139, - }, - { - full_time_student: 'true', - semester_enrollment_type_code: 1, - absence_reason_code: null, - semester_enrollment_date: '2016-06-30T21:00:00.000Z', - semester_code: 138, - }, - ], + data: { + 'hy-opinoik-131106475': [ + { + full_time_student: 'true', + semester_enrollment_type_code: 1, + absence_reason_code: null, + semester_enrollment_date: '2016-06-30T21:00:00.000Z', + semester_code: 139, + }, + { + full_time_student: 'true', + semester_enrollment_type_code: 1, + absence_reason_code: null, + semester_enrollment_date: '2016-06-30T21:00:00.000Z', + semester_code: 138, + }, + ], + }, }, firstYearCredits: 55, }, @@ -239,6 +242,7 @@ const mockData = { admission_date: '2017-06-30T21:00:00.000Z', end_date: '2024-07-30T21:00:00.000Z', start_date: '2017-07-31T21:00:00.000Z', + id: 'hy-opinoik-131106475', }, ], }, @@ -262,22 +266,24 @@ const mockData = { md5: '12345', status: 200, elapsed: 0.002677027, - data: [ - { - full_time_student: 'true', - semester_enrollment_type_code: 1, - absence_reason_code: null, - semester_enrollment_date: '2016-06-30T21:00:00.000Z', - semester_code: 139, - }, - { - full_time_student: 'true', - semester_enrollment_type_code: 1, - absence_reason_code: null, - semester_enrollment_date: '2016-06-30T21:00:00.000Z', - semester_code: 138, - }, - ], + data: { + 'hy-opinoik-131106475': [ + { + full_time_student: 'true', + semester_enrollment_type_code: 1, + absence_reason_code: null, + semester_enrollment_date: '2016-06-30T21:00:00.000Z', + semester_code: 139, + }, + { + full_time_student: 'true', + semester_enrollment_type_code: 1, + absence_reason_code: null, + semester_enrollment_date: '2016-06-30T21:00:00.000Z', + semester_code: 138, + }, + ], + }, }, firstYearCredits: 30, }, diff --git a/server/models/user.js b/server/models/user.js index ed152f7..97ca139 100644 --- a/server/models/user.js +++ b/server/models/user.js @@ -138,7 +138,10 @@ class User extends Model { const flattenEnrolments = flattenEnrolmentsFor(studyrights.map(s => s.id), semesterEnrollments.data) - const isPresent = flattenEnrolments.some(enrollment => ( + console.log(semesterEnrollments.data) + console.log(flattenEnrolments) + + const isPresent = flattenEnrolments && flattenEnrolments.some(enrollment => ( enrollment.semester_code === settings.currentSemester && enrollment.semester_enrollment_type_code === 1)) return {