Skip to main content
Consensus provides a complete voter management system with registration workflows, status tracking, and eligibility controls to ensure secure and compliant elections.

Voter Registration

Voters must register before participating in elections. The registration process includes validation and optional approval workflows.

Registration Process

1

Submit registration

Voters provide their name, email, and password
2

Validation

System validates email format and password strength
3

Approval workflow

Registration enters PENDING status (or APPROVED if auto-approval enabled)
4

Eligibility

Once approved, voters can participate in active elections

Registration Requirements

// From src/services/VoterService.ts:6-10
export interface VoterRegistrationDTO {
    name: string;
    email: string;
    password: string;
}
Validation rules:
  • Must follow standard email format: [email protected]
  • Must be unique across all voters
  • Cannot be changed to an email already in use
// From src/services/VoterService.ts:147-150
private isValidEmail(email: string): boolean {
    const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
    return emailRegex.test(email);
}
  • Minimum 8 characters
  • Stored as hash in production environments
// From src/services/VoterService.ts:34-36
if (dto.password.length < 8) {
    throw new Error("Password must be at least 8 characters");
}
  • Email addresses must be unique
  • Registration fails if email already exists
// From src/services/VoterService.ts:23-26
const existingVoter = this.voterRepository.findByEmail(dto.email);
if (existingVoter) {
    throw new Error("Email already registered");
}

Registration Status

Each voter has a registration status that determines their eligibility to vote.
// From src/domain/enums/index.ts:14-19
export enum RegistrationStatus {
    PENDING = "PENDING",       // Awaiting approval
    APPROVED = "APPROVED",     // Can vote
    REJECTED = "REJECTED",     // Registration denied
    SUSPENDED = "SUSPENDED",   // Temporarily disabled
}

Status Workflow

1

PENDING

Initial status after registration (unless auto-approved)
2

APPROVED

Voter can participate in elections
3

REJECTED

Registration denied - voter cannot access the platform
4

SUSPENDED

Temporarily disabled - can be re-approved if needed
Only voters with APPROVED status can cast votes in elections.

Managing Voter Status

Approving voters:
// From src/services/VoterService.ts:70-78
approveVoter(voterID: string): void {
    const voter = this.voterRepository.findById(voterID);
    if (!voter) {
        throw new Error("Voter not found");
    }

    voter.registrationStatus = RegistrationStatus.APPROVED;
    this.voterRepository.update(voter);
}
Rejecting registrations:
// From src/services/VoterService.ts:83-91
rejectVoter(voterID: string): void {
    const voter = this.voterRepository.findById(voterID);
    if (!voter) {
        throw new Error("Voter not found");
    }

    voter.registrationStatus = RegistrationStatus.REJECTED;
    this.voterRepository.update(voter);
}

Auto-Approval

For open elections or trusted environments, you can enable automatic approval:
// From src/services/VoterService.ts:21
registerVoter(dto: VoterRegistrationDTO, autoApprove: boolean = false): Voter
const voter = voterService.registerVoter({
    name: "John Doe",
    email: "[email protected]",
    password: "securepass123"
}); // Status: PENDING
Auto-approval should only be used in controlled environments where voter identity is verified through external means.

Voter Profile Management

Voters can update their profile information after registration.

Updatable Fields

// From src/services/VoterService.ts:103
updateVoter(voterID: string, updates: { 
    name?: string; 
    email?: string; 
    passwordHash?: string 
}): Voter
Name updates:
  • No restrictions, updated immediately
Email updates:
  • Must pass validation
  • Must not be in use by another voter
  • Changes are validated before applying
// From src/services/VoterService.ts:110-119
if (updates.email && updates.email !== voter.email) {
    const existingVoter = this.voterRepository.findByEmail(updates.email);
    if (existingVoter) {
        throw new Error("Email already registered");
    }
    if (!this.isValidEmail(updates.email)) {
        throw new Error("Invalid email format");
    }
    voter.email = updates.email;
}
Password updates:
  • Should be hashed before passing to update function
  • No minimum length enforced at update (enforced at registration)

Voting Eligibility

Even approved voters must meet additional criteria to cast a vote:
// From src/services/VotingService.ts:51-53
if (voter.registrationStatus !== RegistrationStatus.APPROVED) {
    throw new Error("Voter is not approved");
}
// From src/services/VotingService.ts:62-64
if (election.status !== ElectionStatus.ACTIVE) {
    throw new Error("Election is not active");
}
// From src/services/VotingService.ts:67-70
const now = new Date();
if (now < election.startDate || now > election.endDate) {
    throw new Error("Election is not currently open for voting");
}
// From src/services/VotingService.ts:73-75
if (this.eligibilityRepository.hasVoted(dto.voterID, dto.electionID)) {
    throw new Error("Voter has already voted in this election");
}

Vote Tracking

Consensus tracks that voters have voted while maintaining ballot anonymity.
The system records that a voter voted, but not how they voted. Ballots are stored separately without voter identification.
After casting a vote:
  1. Anonymous ballot stored in ballot repository
  2. Voter marked as having voted (prevents double voting)
  3. Confirmation receipt issued to voter
  4. No link between voter and ballot content
// From src/services/VotingService.ts:124-133
// Store anonymous ballot (no link to voter)
this.ballotRepository.save(anonymousBallot);

// Store confirmation (for voter's records, no vote details)
this.confirmationRepository.save(confirmation);

// Mark voter as having voted
this.eligibilityRepository.markVoted(dto.voterID, dto.electionID);

// Return confirmation
return confirmation;

GDPR Compliance

Voter accounts can be deleted to comply with data protection regulations.
// From src/services/VoterService.ts:136-142
deleteVoter(voterID: string): void {
    const voter = this.voterRepository.findById(voterID);
    if (!voter) {
        throw new Error("Voter not found");
    }
    this.voterRepository.delete(voterID);
}
Deleting a voter removes their registration but does not affect previously cast ballots (which are anonymous). Vote confirmations linked to the voter will also be removed.

Admin Functions

List all voters:
getAllVoters(): Voter[]
Find voter by email:
getVoterByEmail(email: string): Voter | null
Find voter by ID:
getVoterById(voterID: string): Voter | null

Next Steps

Election Management

Create and configure elections for approved voters

Voting Systems

Learn about the voting systems voters will use

Build docs developers (and LLMs) love