Skip to content

Commit

Permalink
Merge pull request #20 from c4dt/more_cleanups
Browse files Browse the repository at this point in the history
More cleanups
  • Loading branch information
ineiti committed Oct 4, 2023
2 parents ac41443 + 61d7ac9 commit 6149677
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 24 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
Latest changes in each category go to the top

## [Unreleased]

### Added
- Changelog - please use it

### Changed
### Deprecated
### Removed
### Fixed
- File formatting and errors in comments
- Popup when voting and some voting translation fixes
- Fixed return error when voting

### Security
- Use `REACT_APP_RANDOMIZE_VOTE_ID === 'true'` to indicate randomizing vote ids
4 changes: 3 additions & 1 deletion scripts/local_vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ 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"
# uncomment this to enable TLS to test gaspar
#export HTTPS=true
# Create random voter-IDs to allow easier testing
export REACT_APP_RANDOMIZE_VOTE_ID="true"
2 changes: 1 addition & 1 deletion services/dkg/pedersen/mod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ func TestPedersen_ComputePubshares_StreamFailed(t *testing.T) {
}

err := a.ComputePubshares()
require.EqualError(t, err, fake.Err("the list of Participants is empty"))
require.EqualError(t, err, "the list of Participants is empty")
}

func TestPedersen_ComputePubshares_SenderFailed(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion web/backend/src/controllers/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const authenticationRouter = express.Router();

authenticationRouter.get('/get_dev_login', (req, res) => {
if (process.env.REACT_APP_DEV_LOGIN !== 'true') {
const err = `/get_dev_login can only be called with DEV_LOGIN===true: ${process.env.DEV_LOGIN}`;
const err = `/get_dev_login can only be called with REACT_APP_DEV_LOGIN===true: ${process.env.REACT_APP_DEV_LOGIN}`;
console.error(err);
res.status(500).send(err);
return;
Expand Down
27 changes: 13 additions & 14 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,24 +242,23 @@ 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;
}

// We must set the UserID to know who this ballot is associated to. This is
// only needed to allow users to cast multiple ballots, where only the last
// ballot is taken into account. To preserve anonymity, the web-backend could
// 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);
} else {
// We must set the UserID to know who this ballot is associated to. This is
// only needed to allow users to cast multiple ballots, where only the last
// ballot is taken into account. To preserve anonymity, the web-backend could
// translate UserIDs to another random ID.

bodyData.UserID = req.session.userId.toString();
}
}

const dataStr = JSON.stringify(bodyData);
Expand Down
4 changes: 2 additions & 2 deletions web/frontend/src/language/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"navBarStatus": "Umfragen",
"navBarHome": "Homepage",
"navBarCreate": "Erstellen",
"vote": "Abstimmung",
"vote": "Abstimmen",
"forms": "Umfragen",
"navBarResult": "Ergebnisse",
"navBarAbout": "Über",
Expand Down Expand Up @@ -167,7 +167,7 @@
"changeVote": "Sie können Ihre Stimme ändern, indem Sie einfach eine neue Stimme abgeben.",
"pickCandidate": "Wählen Sie einen Kandidaten:",
"voteSuccess": "Ihre Stimme wurde erfolgreich abgegeben!",
"voteSuccessful": "Abstimmung erfolgreich",
"voteSuccessful": "Stimmabgabe erfolgreich",
"errorTitle": "Fehler",
"actionChange": "Aktion Ändern",
"notification": "Benachrichtigung",
Expand Down
2 changes: 1 addition & 1 deletion web/frontend/src/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
"alreadyVoted2": "on this form.",
"changeVote": "You can change your vote by simply casting a new vote.",
"pickCandidate": "Pick a candidate:",
"voteSuccess": "Your vote was successfully submitted! VoteID:",
"voteSuccess": "Your vote was successfully submitted!",
"voteSuccessful": "Vote successful",
"errorTitle": "Error",
"actionChange": "Action Change",
Expand Down
4 changes: 1 addition & 3 deletions web/frontend/src/pages/ballot/Show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ const Ballot: FC = () => {
const txt = await response.text();
throw new Error(txt);
}
const res = await response.json();
const id = res.BallotID || 'Not Implemented Yet, see issue 240';
setModalText(`${t('voteSuccess')} ${id}`);
setModalText(t('voteSuccess'));
setModalTitle(t('voteSuccessful'));
} catch (error) {
if (error.message.includes('ECONNREFUSED')) {
Expand Down
2 changes: 1 addition & 1 deletion web/frontend/src/pages/form/Show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const FormShow: FC = () => {
// Fetch result when available after a status change
useEffect(() => {
if (status === Status.ResultAvailable && isResultAvailable) {
getResults(formID, setError, setResult, setIsResultSet);
getResults(formID, setError, setResult, setIsResultSet).then();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isResultAvailable, status]);
Expand Down

0 comments on commit 6149677

Please sign in to comment.