Development

This commit is contained in:
Matthew Grotke 2026-06-08 01:08:24 -04:00
parent 43c4cf380d
commit f011594b04
10 changed files with 163 additions and 46 deletions

View file

@ -62,13 +62,22 @@ def portal_save():
except (ValueError, TypeError):
duration = 0
try:
exp_n = int(request.form.get('default_expiration_value', '0').strip() or '0')
exp_unit = request.form.get('default_expiration_unit', 'hours')
mult = {'hours': 3600, 'days': 86400}.get(exp_unit, 3600)
expiration = exp_n * mult if exp_n > 0 else 0
except (ValueError, TypeError):
expiration = 0
after = {
**existing,
'portal_splash_title': splash_title,
'portal_splash_text': splash_text,
'portal_terms': terms,
'require_username_password': require_upw,
'default_session_seconds': duration,
'portal_splash_title': splash_title,
'portal_splash_text': splash_text,
'portal_terms': terms,
'require_username_password': require_upw,
'default_session_seconds': duration,
'default_expiration_seconds': expiration,
}
vlan['captive_portal'] = after

View file

@ -177,7 +177,7 @@
"input_type": "number",
"min": 0,
"value": "0",
"hint": "How long portal access lasts after authentication. 0 = no expiration."
"hint": "How long portal access lasts after authentication. 0 = no session limit."
},
{
"type": "field",
@ -191,6 +191,31 @@
}
]
},
{
"type": "field_row",
"cols": 2,
"items": [
{
"type": "field",
"label": "Default Expiration Duration",
"name": "default_expiration_value",
"input_type": "number",
"min": 0,
"value": "0",
"hint": "How long after creation an account is valid before it permanently expires. 0 = never expires."
},
{
"type": "field",
"label": "Unit",
"name": "default_expiration_unit",
"input_type": "select",
"options": [
{"value": "hours", "label": "Hours"},
{"value": "days", "label": "Days"}
]
}
]
},
{
"type": "button_row",
"items": [

View file

@ -38,18 +38,20 @@ def collect_tokens(cfg):
text = cp.get('portal_splash_text', vlan.get('portal_splash_text', ''))
terms = cp.get('portal_terms', vlan.get('portal_terms', []))
require_upw = cp.get('require_username_password', vlan.get('require_username_password', False))
duration = cp.get('default_session_seconds', vlan.get('default_session_seconds', 0))
duration = cp.get('default_session_seconds', vlan.get('default_session_seconds', 0))
expiration = cp.get('default_expiration_seconds', vlan.get('default_expiration_seconds', 0))
n = len(terms)
display_rows.append({
'vlan_name': vlan['name'],
'portal_splash_title': title,
'portal_splash_text': text,
'portal_terms': terms,
'portal_terms_display': f'{n} term{"s" if n != 1 else ""}' if n else '--',
'require_upw': require_upw,
'require_username_password': require_upw,
'default_session_seconds': duration,
'session_display': _format_session(duration),
'vlan_name': vlan['name'],
'portal_splash_title': title,
'portal_splash_text': text,
'portal_terms': terms,
'portal_terms_display': f'{n} term{"s" if n != 1 else ""}' if n else '--',
'require_upw': require_upw,
'require_username_password': require_upw,
'default_session_seconds': duration,
'default_expiration_seconds': expiration,
'session_display': _format_session(duration),
})
content = factory.load_json(f'{factory.PAGES_DIR}/captiveportal/content.json')