Skip to content

Commit

Permalink
fix: modify add remove voter perm check
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximeZmt committed Jul 2, 2024
1 parent 8e9babf commit 92aebe4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions contracts/evoting/types/election.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,10 @@ func (form *Form) AddVoter(userID string) error {
return xerrors.Errorf("failed to convert SCIPER to integer: %v", err)
}

if form.Status != Initial {
return xerrors.Errorf("Cannot add voter. The form is not in Initial status but %v", form.Status)
}

form.Voters = append(form.Voters, sciperInt)

return nil
Expand Down Expand Up @@ -456,6 +460,10 @@ func (form *Form) RemoveVoter(userID string) error {
return xerrors.Errorf("Error while retrieving the index of the element.")
}

if form.Status != Initial {
return xerrors.Errorf("Cannot remove voter. The form is not in Initial status but %v", form.Status)
}

form.Voters = append(form.Voters[:index], form.Voters[index+1:]...)
return nil
}
Expand Down

0 comments on commit 92aebe4

Please sign in to comment.