Use server session check for access
This commit is contained in:
@@ -31,6 +31,8 @@ Home Assistant에 기록된 Galaxy 기기의 위치, 배터리, 활동 상태,
|
|||||||
|
|
||||||
인증과 Home Assistant 호출은 `/custom/common`을 사용합니다. 브라우저 JS에는 더 이상 API Bearer 토큰이나 Home Assistant 웹훅 식별자를 직접 넣지 않습니다.
|
인증과 Home Assistant 호출은 `/custom/common`을 사용합니다. 브라우저 JS에는 더 이상 API Bearer 토큰이나 Home Assistant 웹훅 식별자를 직접 넣지 않습니다.
|
||||||
|
|
||||||
|
접근 확인은 JS에서 읽을 수 있는 레거시 쿠키가 아니라 `/custom/launcher/api.php?session=1` 서버 응답으로 처리합니다. 공통 인증 쿠키는 `HttpOnly`이므로 브라우저 스크립트가 직접 읽지 않습니다.
|
||||||
|
|
||||||
표시할 모바일 앱 센서 목록은 `/custom/common/config.php`의 `findmydevice_sensor_sections`에서 섹션 단위로 관리합니다. 화면 CSS 원본은 `/custom/common/css/findmydevice.css`를 사용합니다. 기존 운영 HTML이 `/custom/findmydevice/css/style.css`를 참조해도 호환 파일이 공용 CSS를 import합니다.
|
표시할 모바일 앱 센서 목록은 `/custom/common/config.php`의 `findmydevice_sensor_sections`에서 섹션 단위로 관리합니다. 화면 CSS 원본은 `/custom/common/css/findmydevice.css`를 사용합니다. 기존 운영 HTML이 `/custom/findmydevice/css/style.css`를 참조해도 호환 파일이 공용 CSS를 import합니다.
|
||||||
|
|
||||||
## 운영 메모
|
## 운영 메모
|
||||||
|
|||||||
+10
-5
@@ -434,11 +434,16 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
return (window.matchMedia('(display-mode: standalone)').matches) || (window.navigator.standalone === true);
|
return (window.matchMedia('(display-mode: standalone)').matches) || (window.navigator.standalone === true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 조건: /findmydevice로 시작하고 access 쿠키가 없으며, PWA가 아닌 경우에만 리디렉션
|
if (location.pathname.startsWith('/findmydevice') && !isInStandaloneMode()) {
|
||||||
if (location.pathname.startsWith('/findmydevice') && getCookie('access') !== '9KxH6236' && !isInStandaloneMode()) {
|
fetch('/custom/launcher/api.php?session=1', { credentials: 'same-origin' })
|
||||||
location.replace('/blog');
|
.then(res => res.ok ? res.json() : Promise.reject())
|
||||||
return; // 이하 코드 실행 방지
|
.then(session => {
|
||||||
}
|
if (!session.authenticated) {
|
||||||
|
location.replace('/blog');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => location.replace('/blog'));
|
||||||
|
}
|
||||||
|
|
||||||
const btnArea = document.querySelector('body > div.btnArea');
|
const btnArea = document.querySelector('body > div.btnArea');
|
||||||
const pageModifyLink = btnArea?.querySelectorAll('a')[1]?.getAttribute('href') || '';
|
const pageModifyLink = btnArea?.querySelectorAll('a')[1]?.getAttribute('href') || '';
|
||||||
|
|||||||
Reference in New Issue
Block a user