Skip to content

Commit

Permalink
@pierluca's comments
Browse files Browse the repository at this point in the history
- check doesn't work
- use variable for randomizing vote ID
  • Loading branch information
ineiti committed Oct 4, 2023
1 parent 25a6f91 commit 7ac843e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 3 additions & 1 deletion scripts/local_vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ export DB_PATH="$(pwd)/nodes/llmdb"
# The following two variables can be set to see log output from dela:
#export PROXY_LOG=info
#export LLVL=info
# If this is set, you can login without Gaspar
# Logging in without Gaspar and SCIPER 100100
export REACT_APP_DEV_LOGIN="true"
# Create random voter-IDs to allow easier testing
export REACT_APP_RANDOMIZE_VOTE_ID="true"
14 changes: 6 additions & 8 deletions web/backend/src/controllers/dela.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ delaRouter.delete('/forms/:formID', (req, res) => {
// request that needs to go the DELA nodes
delaRouter.use('/*', (req, res) => {
if (!req.session.userId) {
res.status(400).send('Unauthorized');
res.status(401).send('Authentication required!');
return;
}

Expand All @@ -242,10 +242,6 @@ delaRouter.use('/*', (req, res) => {
// special case for voting
const match = req.baseUrl.match('/api/evoting/forms/(.*)/vote');
if (match) {
if (!req.session.userId) {
res.status(401).send('Authentication required!');
return;
}
if (!isAuthorized(req.session.userId, match[1], PERMISSIONS.ACTIONS.VOTE)) {
res.status(400).send('Unauthorized');
return;
Expand All @@ -257,9 +253,11 @@ delaRouter.use('/*', (req, res) => {
// translate UserIDs to another random ID.
// bodyData.UserID = req.session.userId.toString();

// DEBUG: this is only for debugging and needs to be replaced before production
console.warn('DEV CODE - randomizing the SCIPER ID to allow for unlimited votes');
bodyData.UserID = makeid(10);
if (process.env.REACT_APP_RANDOMIZE_VOTE_ID === 'true') {
// DEBUG: this is only for debugging and needs to be replaced before production
console.warn('DEV CODE - randomizing the SCIPER ID to allow for unlimited votes');
bodyData.UserID = makeid(10);
}
}

const dataStr = JSON.stringify(bodyData);
Expand Down

0 comments on commit 7ac843e

Please sign in to comment.