Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Added:
- **Internet schedule** (new page). Turn the internet off at set times of the week for chosen people (all their devices) or single devices: bedtime on school nights, study time, meal times. One click starts from a ready plan ("School nights", "Every night", "Study time", "Meal times"); a schedule can have several times, a time can run past midnight, and dates can be marked as days off (holidays, Eid). **Bonus time** gives a few extra minutes without changing the schedule. **Always allowed** sites (a school platform, a study site) keep working during every schedule. While a schedule is on, the device's card shows when the internet comes back, the home network (printer, shared drives, the dashboard) keeps working, and the cut is done by the gateway itself, so it works on any phone, tablet, TV or console with no app. Each device gets its end time in the system kernel, so it comes back online on time even if the gateway service restarts or stops. Sites on the "always allowed" list only open on devices that look names up through the gateway; a phone with Private DNS (or a browser with secure DNS) turned on keeps them blocked during a schedule. Contributed by @amr-elgharip2006. Closes #32.

Fixed:
- The guest waiting page: entering a guest code now also works when the same browser is logged in to the dashboard, the "start browsing" button gets the focus after approval, hidden parts stay hidden, and the pulsing animation stops for people who turned off motion on their device. Contributed by @compnew2006.
- Website block/allow rules were rebuilt every time the gateway started, so their numbers changed on each restart. They are now kept as they are. If an older version was interrupted in the middle of that rebuild (for example by a power cut), the rules it left behind are put back on the next start instead of being lost. Contributed by @compnew2006.

## [0.5.11] — 2026-11-24
Expand Down
19 changes: 19 additions & 0 deletions tests/test_guest_captive.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,25 @@ def test_guest_pending_page_serves_html(captive_env):
assert "Netrex" in r.text


def test_guest_portal_hidden_states_and_reduced_motion(captive_env):
_, _, _, app = captive_env
with TestClient(app) as client:
html = client.get("/guest/pending").text

assert "[hidden]" in html and "display: none !important" in html
assert "@media (prefers-reduced-motion: reduce)" in html
assert "voucherForm.contains(document.activeElement)" in html
assert "document.getElementById('browse-btn').focus()" in html


def test_guest_voucher_redemption_sends_csrf_header(captive_env):
_, _, _, app = captive_env
with TestClient(app) as client:
html = client.get("/guest/pending").text

assert "'X-QM-CSRF': '1'" in html


def test_captive_probes_redirect_pending_guests(captive_env):
database, service, holder, app = captive_env

Expand Down
9 changes: 8 additions & 1 deletion web/guest_pending.html
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@
margin: 16px 0 20px;
text-align: start;
}
[hidden] { display: none !important; }
.voucher-form label { color: var(--text); font-size: .9rem; font-weight: 600; }
.voucher-form input {
width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px;
Expand All @@ -272,6 +273,10 @@
0%, 100% { opacity: 1; transform: scale(1); }
50% { opacity: 0.3; transform: scale(0.85); }
}
@media (prefers-reduced-motion: reduce) {
.live-indicator, .pulse-ring { animation: none; }
.pulse-ring { display: none; }
}

.btn {
width: 100%;
Expand Down Expand Up @@ -451,7 +456,7 @@ <h2 id="headline-en">Awaiting Administrator Approval</h2>
const response = await fetch('/api/guest/voucher/redeem', {
method: 'POST',
credentials: 'same-origin',
headers: { 'Content-Type': 'application/json' },
headers: { 'Content-Type': 'application/json', 'X-QM-CSRF': '1' },
body: JSON.stringify({ code: voucherCode.value.trim() })
});
const errorBody = !response.ok
Expand Down Expand Up @@ -545,6 +550,7 @@ <h2 id="headline-en">Awaiting Administrator Approval</h2>
const msgEn = document.getElementById('msg-en');
const liveBox = document.getElementById('live-status-box');
const actionBox = document.getElementById('action-container');
const voucherHadFocus = voucherForm.contains(document.activeElement);
voucherForm.hidden = data.status !== 'pending';

if (data.approved || (!data.blocked && data.is_guest) || (data.status === 'ok' && !data.is_guest)) {
Expand Down Expand Up @@ -576,6 +582,7 @@ <h2 id="headline-en">Awaiting Administrator Approval</h2>
🌐 تصفح الإنترنت الآن (Start Browsing)
</a>
`;
if (voucherHadFocus) document.getElementById('browse-btn').focus();

// Start countdown to redirect
let sec = 3;
Expand Down
Loading