Development
This commit is contained in:
parent
2bb876ed97
commit
c01e240bd7
2 changed files with 9 additions and 9 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -160,8 +160,9 @@
|
|||
"label": "Valid For",
|
||||
"name": "valid_for_value",
|
||||
"input_type": "number",
|
||||
"min": 1,
|
||||
"hint": "How long this credential is valid after creation. Leave blank for no expiry."
|
||||
"min": 0,
|
||||
"value": "0",
|
||||
"hint": "How long this credential is valid after creation. 0 = no expiration."
|
||||
},
|
||||
{
|
||||
"type": "field",
|
||||
|
|
@ -169,9 +170,8 @@
|
|||
"name": "valid_for_unit",
|
||||
"input_type": "select",
|
||||
"options": [
|
||||
{"value": "never", "label": "Never (no expiry)"},
|
||||
{"value": "hours", "label": "Hours"},
|
||||
{"value": "days", "label": "Days"}
|
||||
{"value": "hours", "label": "Hours"},
|
||||
{"value": "days", "label": "Days"}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue