Skip to content

Commit

Permalink
cast GitHub voter usernames to lowercase
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Shen <[email protected]>
  • Loading branch information
mjlshen committed Sep 12, 2023
1 parent 27f236d commit 0d01cd9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion elekto/models/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ def results(self):
return utils.parse_md(os.path.join(self.path, Election.RES))

def voters(self):
return utils.parse_yaml(os.path.join(self.path, Election.VOT))
voters = utils.parse_yaml(os.path.join(self.path, Election.VOT))
voters['eligible_voters'] = [voter.lower() for voter in voters['eligible_voters']]
return voters

def showfields(self):
return dict.fromkeys(self.election['show_candidate_fields'], '')
Expand Down
1 change: 1 addition & 0 deletions elekto/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def set_session(app):
# if unable to fetch the user's info, set auth to False
if user and user.token_expires_at and user.token_expires_at > datetime.now():
F.g.user = user
F.g.user.username = F.g.user.username.lower()
F.g.auth = True
# Find all the user's past and all upcoming (meta only) elections
query = SESSION.query(Election).join(
Expand Down

0 comments on commit 0d01cd9

Please sign in to comment.