@@ -64,6 +64,11 @@ async function updateSettings(req, res, next) {
6464 * @description Confirms that openTime < closeTime < confirmTime
6565 */
6666function confirmValidPatch ( req , res , next ) {
67+ if ( ! req . body . settingsDetails . openTime &&
68+ ! req . body . settingsDetails . closeTime &&
69+ ! req . body . settingsDetails . confirmTime ) {
70+ return next ( ) ;
71+ }
6772 const openTime = new Date ( req . body . settingsDetails . openTime ) ;
6873 const closeTime = new Date ( req . body . settingsDetails . closeTime ) ;
6974 const confirmTime = new Date ( req . body . settingsDetails . confirmTime ) ;
@@ -126,9 +131,35 @@ async function confirmAppsOpen(req, res, next) {
126131 }
127132}
128133
134+ /**
135+ * @function confirmCheckinOpen
136+ * @param {* } req
137+ * @param {* } res
138+ * @param {* } next
139+ * @description Only succeeds if check-in is currently open
140+ */
141+ async function confirmCheckinOpen ( req , res , next ) {
142+ const settings = await Services . Settings . getSettings ( ) ;
143+ if ( ! settings ) {
144+ return next ( {
145+ status : 500 ,
146+ message : Constants . Error . GENERIC_500_MESSAGE
147+ } ) ;
148+ }
149+ if ( settings . checkinOpen ) {
150+ return next ( ) ;
151+ }
152+
153+ return next ( {
154+ status : 403 ,
155+ message : Constants . Error . SETTINGS_403_MESSAGE
156+ } ) ;
157+ }
158+
129159module . exports = {
130160 parsePatch : parsePatch ,
131161 confirmValidPatch : confirmValidPatch ,
162+ confirmCheckinOpen : Middleware . Util . asyncMiddleware ( confirmCheckinOpen ) ,
132163 confirmAppsOpen : Middleware . Util . asyncMiddleware ( confirmAppsOpen ) ,
133164 updateSettings : Middleware . Util . asyncMiddleware ( updateSettings ) ,
134165 getSettings : Middleware . Util . asyncMiddleware ( getSettings )
0 commit comments