Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
mluukkai committed Jan 26, 2024
1 parent 7a40e83 commit 6e87fa9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 33 deletions.
2 changes: 2 additions & 0 deletions server/middleware/authenticationMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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!')
Expand Down
70 changes: 38 additions & 32 deletions server/models/lib/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,32 @@ 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',
},
],
},
semesterEnrollments: {
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,
},
Expand Down Expand Up @@ -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',
},
],
},
Expand All @@ -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,
},
Expand Down
5 changes: 4 additions & 1 deletion server/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 6e87fa9

Please sign in to comment.