From d471799c5c5b9939781939a63bab9c08bc333490 Mon Sep 17 00:00:00 2001 From: seo Date: Fri, 26 Jun 2026 19:31:20 +0900 Subject: [PATCH] =?UTF-8?q?=EB=82=98=EC=9D=98=20=EC=B0=BE=EA=B8=B0=20?= =?UTF-8?q?=EC=9D=B8=EC=A6=9D=20=EC=95=88=EB=82=B4=20=ED=99=94=EB=A9=B4=20?= =?UTF-8?q?=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- js/main.js | 33 ++++++++++++++++++++------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index c38783a..f575aec 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Home Assistant에 기록된 Galaxy Z Fold7의 위치, 배터리, 활동 상태, 인증과 Home Assistant 호출은 `/custom/common`을 사용합니다. 브라우저 JS에는 더 이상 API Bearer 토큰이나 Home Assistant 웹훅 식별자를 직접 넣지 않습니다. -접근 확인은 JS에서 읽을 수 있는 레거시 쿠키가 아니라 `/custom/launcher/api.php?session=1` 서버 응답으로 처리합니다. 공통 인증 쿠키는 `HttpOnly`이므로 브라우저 스크립트가 직접 읽지 않습니다. +접근 확인은 JS에서 읽을 수 있는 레거시 쿠키가 아니라 `/custom/launcher/api.php?session=1` 서버 응답으로 처리합니다. 공통 인증 쿠키는 `HttpOnly`이므로 브라우저 스크립트가 직접 읽지 않습니다. 미인증 접근은 `/blog`로 강제 이동하지 않고 현재 화면 안에 인증 필요 안내를 표시합니다. PWA standalone 여부와 관계없이 같은 세션 확인을 수행합니다. 표시할 모바일 앱 센서 목록은 `/custom/common/config.php`의 `findmydevice_sensor_sections`에서 섹션 단위로 관리합니다. 화면 CSS 원본은 `/custom/common/css/findmydevice.css`를 사용합니다. 기존 운영 HTML이 `/custom/findmydevice/css/style.css`를 참조해도 호환 파일이 공용 CSS를 import합니다. diff --git a/js/main.js b/js/main.js index 553fac5..2fe45e2 100644 --- a/js/main.js +++ b/js/main.js @@ -539,21 +539,28 @@ document.addEventListener('DOMContentLoaded', () => { location.href = '/blog'; }); - // PWA 상태인지 확인 (iOS 및 기타 브라우저 지원) - function isInStandaloneMode() { - return (window.matchMedia('(display-mode: standalone)').matches) || (window.navigator.standalone === true); + function renderAuthErrorPage() { + document.body.innerHTML = ` +
+
+

인증이 필요합니다

+

런처에서 관리자 세션 또는 공통 비밀번호 인증을 완료한 뒤 나의 찾기에 접속할 수 있습니다.

+ 런처로 이동 +
+
+ `; } - if (location.pathname.startsWith('/findmydevice') && !isInStandaloneMode()) { - fetch('/custom/launcher/api.php?session=1', { credentials: 'same-origin' }) - .then(res => res.ok ? res.json() : Promise.reject()) - .then(session => { - if (!session.authenticated) { - location.replace('/blog'); - } - }) - .catch(() => location.replace('/blog')); - } + if (location.pathname.startsWith('/findmydevice')) { + fetch('/custom/launcher/api.php?session=1', { credentials: 'same-origin' }) + .then(res => res.ok ? res.json() : Promise.reject()) + .then(session => { + if (!session.authenticated) { + renderAuthErrorPage(); + } + }) + .catch(renderAuthErrorPage); + } const btnArea = document.querySelector('body > div.btnArea'); const pageModifyLink = btnArea?.querySelectorAll('a')[1]?.getAttribute('href') || '';