@@ -292,34 +292,23 @@ app.use('/api/evoting/*', (req, res, next) => {
292
292
// controlled. Once this is done the data are signed before the are sent to the
293
293
// DELA node To make this work, react has to redirect to this backend all the
294
294
// request that needs to go the DELA nodes
295
- app . use ( '/api/evoting/*' , ( req , res , next ) => {
295
+ app . use ( '/api/evoting/*' , ( req , res ) => {
296
296
if ( ! req . session . userid ) {
297
297
res . status ( 400 ) . send ( 'Unauthorized' ) ;
298
298
return ;
299
299
}
300
300
301
301
const bodyData = req . body ;
302
302
303
- const dataStr = JSON . stringify ( bodyData ) ;
304
-
305
303
// special case for voting
306
304
const regex = / \/ a p i \/ e v o t i n g \/ e l e c t i o n s \/ .* \/ v o t e / ;
307
305
if ( req . baseUrl . match ( regex ) ) {
308
- // will be handled by the next matcher, just bellow
309
- next ( ) ;
310
- } else {
311
- sendToDela ( dataStr , req , res ) ;
306
+ // We must set the UserID to know who this ballot is associated to. This is
307
+ // only needed to allow users to cast multiple ballots, where only the last
308
+ // ballot is taken into account. To preserve anonymity the web-backend could
309
+ // translate UserIDs to another random ID.
310
+ bodyData . UserID = req . session . userid . toString ( ) ;
312
311
}
313
- } ) ;
314
-
315
- app . post ( '/api/evoting/elections/:electionID/vote' , ( req , res ) => {
316
- const bodyData = req . body ;
317
-
318
- // We must set the UserID to know who this ballot is associated to. This is
319
- // only needed to allow users to cast multiple ballots, where only the last
320
- // ballot is taken into account. To preserve anonymity the web-backend could
321
- // translate UserIDs to another random ID.
322
- bodyData . UserID = req . session . userid ;
323
312
324
313
const dataStr = JSON . stringify ( bodyData ) ;
325
314
0 commit comments