-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing voting #371
Fixing voting #371
Conversation
Using the endpoint 'forms/:formID/vote' doesn't work with the sendToDela method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor remarks :)
if (!req.session.userId) { | ||
res.status(401).send('Authentication required!'); | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will never be called based on the code in line 235-237.
That error should probably return a 401, like you've done here.
@@ -263,6 +238,30 @@ delaRouter.use('/*', (req, res) => { | |||
} | |||
|
|||
const bodyData = req.body; | |||
|
|||
// special case for voting | |||
const match = req.baseUrl.match('/api/evoting/forms/(.*)/vote'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not set this up as a specific endpoint ? It would be more idiomatic, unless I'm missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what we did, but then sendToDela
fails, because it uses baseUrl
, which is different in delaRouter.Post
and delaRouter.use
.
// 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use a global env. variable to define if we're in debug or not, instead of commenting out ? I'm afraid something like this will make its way back into production someday when someone's looking in the other direction :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely better to use a global variable. One of the problems is that we cannot use NODE_ENV === 'development'
, as we currently need to run the frontend in development mode due to the proxying.
Closing this in favour of c4dt#20 |
Using the endpoint 'forms/:formID/vote' doesn't work with the sendToDela method