11import { NextFunction , Request , Response } from 'express'
22import { CustomError , UnauthorizedUserError } from 'ntnui-tools/customError'
33import { CommitteeModel } from '../models/Committee'
4- import { ELECTION_COMMITTEE_ID , MAIN_BOARD_ID , LAW_COMMITTEE_ID } from '../utils/constants'
4+ import {
5+ ELECTION_COMMITTEE_ID ,
6+ MAIN_BOARD_ID ,
7+ LAW_COMMITTEE_ID ,
8+ } from '../utils/constants'
59import { RequestWithNtnuiNo } from '../utils/request'
610import { getUserRoleInCommitteeByUserId } from '../utils/userCommittee'
711
@@ -14,7 +18,7 @@ const getCommittees = (_req: Request, res: Response) => {
1418async function acceptAdmissions (
1519 req : RequestWithNtnuiNo ,
1620 res : Response ,
17- next : NextFunction
21+ next : NextFunction ,
1822) {
1923 try {
2024 const { ntnuiNo } = req
@@ -34,12 +38,12 @@ async function acceptAdmissions(
3438 committee . _id !== MAIN_BOARD_ID ) ||
3539 // If user part of election committee, allow toggle of own, main board and the law committee
3640 ( userCommittee . committee === ELECTION_COMMITTEE_ID &&
37- committee . _id === userCommittee . committee ||
38- committee . _id === MAIN_BOARD_ID ||
39- committee . _id === LAW_COMMITTEE_ID ) ||
41+ committee . _id === userCommittee . committee ) ||
42+ committee . _id === MAIN_BOARD_ID ||
43+ committee . _id === LAW_COMMITTEE_ID ||
4044 // If user is board member of the committee and is not in the main board
4145 ( userCommittee . committee === committee . _id &&
42- committee . _id !== MAIN_BOARD_ID )
46+ committee . _id !== MAIN_BOARD_ID ) ,
4347 )
4448 if ( isAuthorized ) {
4549 // Toggle accepts_admissions for a committee
@@ -50,13 +54,13 @@ async function acceptAdmissions(
5054 . then ( ( ) =>
5155 res . status ( 200 ) . json ( {
5256 accepts_admissions : committee . accepts_admissions ,
53- } )
57+ } ) ,
5458 )
5559 . catch ( ( err ) => res . status ( 500 ) . json ( { message : err . message } ) )
5660 }
5761 throw new CustomError (
5862 'You are not authorized to change the admission status of this committee' ,
59- 403
63+ 403 ,
6064 )
6165 } catch ( error ) {
6266 return next ( error )
0 commit comments