Skip to content

Commit

Permalink
Check none type scratch codes (#1459)
Browse files Browse the repository at this point in the history
  • Loading branch information
Carson-Tang authored Jun 17, 2020
1 parent 4188578 commit e21d8ad
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion judge/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def clean(self):
elif self.profile.is_totp_enabled and totp_or_scratch_code:
if pyotp.TOTP(self.profile.totp_key).verify(totp_or_scratch_code, valid_window=self.TOLERANCE):
return
elif totp_or_scratch_code in json.loads(self.profile.scratch_codes):
elif self.profile.scratch_codes and totp_or_scratch_code in json.loads(self.profile.scratch_codes):
scratch_codes = json.loads(self.profile.scratch_codes)
scratch_codes.remove(totp_or_scratch_code)
self.profile.scratch_codes = json.dumps(scratch_codes)
Expand Down

0 comments on commit e21d8ad

Please sign in to comment.