Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const sendEmailsController = async (req: IElectionRequest, res: Response, next:

const Jobs: email_request_event[] = []
const reqId = req.contextId ? req.contextId : randomUUID();
const url = req.protocol + '://' + req.get('host')
const url = ServiceLocator.globalData().mainUrl;
electionRoll.forEach(roll => {
Jobs.push(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const sendInvitationsController = async (req: IElectionRequest, res: Response, n
async function sendBatchEmailInvites(req: any, electionRoll: ElectionRoll[], election: Election) {
const Jobs: SendInviteEvent[] = []
const reqId = req.contextId ? req.contextId : randomUUID();
const url = req.protocol + '://' + req.get('host')
const url = ServiceLocator.globalData().mainUrl;
electionRoll.forEach(roll => {
Jobs.push(
{
Expand Down Expand Up @@ -97,7 +97,7 @@ const sendInvitationController = async (req: any, res: any, next: any) => {
if (!(req.election.settings.voter_access === 'closed' && req.election.settings.invitation === 'email')) {
throw new BadRequest('Email invitations not enabled')
}
const url = req.protocol + '://' + req.get('host')
const url = ServiceLocator.globalData().mainUrl;

const electionId = req.election.election_id;
const election = req.election
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/Services/Email/EmailTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function makeEmails(election: Election, voters: ElectionRoll[], url: stri
return formatMarkdown(body, {
allowButtons: true,
buttonContext: {
voteUrl: `${url}/${election.election_id}/${election.settings.voter_authentication.voter_id === true && 'id/' + voter_id}`,
voteUrl: `${url}/${election.election_id}${election.settings.voter_authentication.voter_id ? '/id/' + voter_id : ''}`,
electionHomeUrl: `${url}/${election.election_id}`
}
});
Expand Down Expand Up @@ -65,7 +65,7 @@ export function Invites(election: Election, voters: ElectionRoll[], url: string,

<p>Click the button to vote:</p>

${makeButton('Vote', `${url}/${election.election_id}/${election.settings.voter_authentication.voter_id === true && 'id/' + voter.voter_id}`)}
${makeButton('Vote', `${url}/${election.election_id}${election.settings.voter_authentication.voter_id ? '/id/' + voter.voter_id : ''}`)}

<p>This link is unique to you, be careful not to share this email with others</p>
`)
Expand Down
4 changes: 3 additions & 1 deletion packages/backend/src/Services/GlobalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ export default class GlobalData {
mainUrl:string;

constructor() {
this.mainUrl = process.env.MAIN_URL || "https://bettervoting.com";
let url = process.env.MAIN_URL || "https://bettervoting.com";
if (url.endsWith('/')) url = url.slice(0, -1);
this.mainUrl = url;
}
}