diff --git a/docker/routlin-dash/app/pages/clientcredentials/action.py b/docker/routlin-dash/app/pages/clientcredentials/action.py index c47a83d..2bd2337 100644 --- a/docker/routlin-dash/app/pages/clientcredentials/action.py +++ b/docker/routlin-dash/app/pages/clientcredentials/action.py @@ -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: diff --git a/docker/routlin-dash/app/pages/clientcredentials/content.json b/docker/routlin-dash/app/pages/clientcredentials/content.json index 1dd5ccb..9024da4 100644 --- a/docker/routlin-dash/app/pages/clientcredentials/content.json +++ b/docker/routlin-dash/app/pages/clientcredentials/content.json @@ -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"} ] } ]