Skip to content

Commit d431e0e

Browse files
authored
Merge pull request #116 from dedis/web-backend-voting
Fixes the web-backend on the voting endpoint
2 parents 73b629a + 9c2cb31 commit d431e0e

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

web/backend/src/Server.ts

+6-17
Original file line numberDiff line numberDiff line change
@@ -292,34 +292,23 @@ app.use('/api/evoting/*', (req, res, next) => {
292292
// controlled. Once this is done the data are signed before the are sent to the
293293
// DELA node To make this work, react has to redirect to this backend all the
294294
// request that needs to go the DELA nodes
295-
app.use('/api/evoting/*', (req, res, next) => {
295+
app.use('/api/evoting/*', (req, res) => {
296296
if (!req.session.userid) {
297297
res.status(400).send('Unauthorized');
298298
return;
299299
}
300300

301301
const bodyData = req.body;
302302

303-
const dataStr = JSON.stringify(bodyData);
304-
305303
// special case for voting
306304
const regex = /\/api\/evoting\/elections\/.*\/vote/;
307305
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();
312311
}
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;
323312

324313
const dataStr = JSON.stringify(bodyData);
325314

0 commit comments

Comments
 (0)