Development

This commit is contained in:
Matthew Grotke 2026-06-07 01:43:04 -04:00
parent 2bb876ed97
commit c01e240bd7
2 changed files with 9 additions and 9 deletions

View file

@ -104,13 +104,13 @@ def _hash_password(plaintext, hash_type):
def _parse_valid_for(value_str, unit_str):
"""Return valid_for in seconds (int) or None for no expiry."""
"""Return valid_for in seconds (int) or None for no expiry. Value of 0 means no expiry."""
unit_str = (unit_str or '').strip()
if unit_str == 'never' or not value_str or not value_str.strip():
if not value_str or not value_str.strip():
return None
try:
n = int(value_str.strip())
if n < 1:
if n <= 0:
return None
except (ValueError, TypeError):
return None
@ -124,7 +124,7 @@ def _parse_valid_for(value_str, unit_str):
def _valid_for_to_display(valid_for):
"""Return (value_str, unit_str) for form pre-population."""
if valid_for is None:
return '', 'never'
return '0', 'hours'
if valid_for % 86400 == 0:
return str(valid_for // 86400), 'days'
if valid_for % 3600 == 0: