Three intertwined bodies of work developed and tested together this session. Full test suite green: python (edge) + phpunit (cloud). ## Edge/Pi install path - setup_online.sh: apt-lock retry (apt-daily contention), Type=exec unit + StartLimitIntervalSec in [Unit], journalctl-on-failure, crash-loop detection. - onnxruntime is now best-effort (no sdist / no 32-bit-ARM wheel); [6/8] probes the real backend and hard-fails if none works. - Hailo HEF auto-fetch: edge/tools/fetch_hailo_hef.py (pinned sha256, refuses to guess 8 vs 8L, HAILO_ARCH override for serial-less boards); hailo_pose.py run() timeout fix. - install_offline.sh: mirrors the backend gate; onnxruntime optional. ## Cafe24 cloud package (cloud/deploy/) - build_cafe24_package.sh emits move_detect_app/ (private, one folder) + www/move_detect/ (docroot subdir); no-dev classmap autoloader; preflight.php; hardened .htaccess. - Subdirectory mount support: Request::baseFrom/pathFor strip the mount prefix; index.php walks up to find the app root; views/JS prefix every URL with APP_BASE; session cookie scoped to the mount. ## Delivery audit — silent-failure & correctness (docs/delivery-audit.md) All 4 blockers + all Phase-1 silent-failure + Phase-2 HIGH correctness: - Edge cloud clients send a custom User-Agent (cafe24 WAF blocks python-requests) and allow_redirects=False. - Daemon fails loud on blank CAFE24_URL/DEVICE_SECRET; run_loop logs swallowed exceptions; heartbeat carries real fps + per-camera health; UvcSource reopens a dead camera; offline queue is size-capped and drops poison rows; TARGET_FPS/QUEUE_DB validated. - Zone coordinates normalized 0..1 on both sides (were canvas-px vs camera-px — every zone misplaced); pinch zones emit PINCH/HIGH (were downgraded to WARNING). - Fall detection uses bbox cues when keypoints are low-confidence (occluded fallen person); ghost incident not cancelled by a bystander; displacement normalized per-second (FPS-invariant). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019Xmn8KZWqiQUguEMRtn6rW
79 lines
2.3 KiB
JavaScript
79 lines
2.3 KiB
JavaScript
/**
|
|
* Login form handler: intercepts form submission and submits via fetch.
|
|
* On success (200), redirects to dashboard. On error (401/423), shows
|
|
* the #login-error element with a user-friendly message.
|
|
*
|
|
* XSS-safe: all dynamic values are set via textContent, never innerHTML.
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
// Mount prefix: '' at the web root, '/move_detect' when the app shares a www/ with another
|
|
// site. Injected by src/View/layout.php from the server's SCRIPT_NAME.
|
|
var B = window.APP_BASE || '';
|
|
|
|
var form = document.querySelector('.login-form');
|
|
if (!form) return;
|
|
|
|
var errorEl = document.getElementById('login-error');
|
|
|
|
form.addEventListener('submit', function (e) {
|
|
e.preventDefault();
|
|
|
|
// Hide any previous error message
|
|
if (errorEl) {
|
|
errorEl.setAttribute('hidden', '');
|
|
errorEl.textContent = '';
|
|
}
|
|
|
|
// Collect form data and convert to application/x-www-form-urlencoded
|
|
var formData = new FormData(form);
|
|
var body = new URLSearchParams(formData).toString();
|
|
|
|
fetch(B + '/login', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
body: body
|
|
})
|
|
.then(function (res) {
|
|
if (res.status === 200) {
|
|
// Success: redirect to dashboard
|
|
window.location.href = B + '/';
|
|
return null;
|
|
}
|
|
// Error: parse response and show error message
|
|
if (!res.ok) throw new Error('login_failed:' + res.status);
|
|
return res.json();
|
|
})
|
|
.then(function (data) {
|
|
if (data && data.error) {
|
|
showError(data.error);
|
|
}
|
|
})
|
|
.catch(function (err) {
|
|
// Extract status code from error message if available
|
|
var status = /login_failed:(\d+)/.exec(String(err)) ? parseInt(RegExp.$1) : 0;
|
|
if (status === 401 || status === 0) {
|
|
showError('invalid_credentials');
|
|
} else if (status === 423) {
|
|
showError('locked');
|
|
}
|
|
});
|
|
});
|
|
|
|
function showError(errorCode) {
|
|
if (!errorEl) return;
|
|
|
|
var message;
|
|
if (errorCode === 'invalid_credentials') {
|
|
message = '로그인 실패';
|
|
} else if (errorCode === 'locked') {
|
|
message = '계정 잠김';
|
|
} else {
|
|
message = '로그인 실패';
|
|
}
|
|
|
|
errorEl.textContent = message;
|
|
errorEl.removeAttribute('hidden');
|
|
}
|
|
})();
|