PWA 나의 찾기 인증 흐름 정리
This commit is contained in:
+11
-3
@@ -466,7 +466,10 @@ const BACK_LINK_PATH_TITLE = {
|
||||
'/blog': '블로그',
|
||||
};
|
||||
const FINDMYDEVICE_AUTH_REQUIRED = location.pathname.startsWith('/findmydevice');
|
||||
let findmydeviceAuthenticated = !FINDMYDEVICE_AUTH_REQUIRED;
|
||||
function isStandalonePwa() {
|
||||
return window.navigator.standalone || window.matchMedia('(display-mode: standalone)').matches;
|
||||
}
|
||||
let findmydeviceAuthenticated = !FINDMYDEVICE_AUTH_REQUIRED || isStandalonePwa();
|
||||
|
||||
function renderAuthErrorPage() {
|
||||
document.body.innerHTML = `
|
||||
@@ -493,6 +496,7 @@ function renderAuthErrorPage() {
|
||||
}
|
||||
|
||||
const findmydeviceAuthPromise = FINDMYDEVICE_AUTH_REQUIRED
|
||||
&& !isStandalonePwa()
|
||||
? fetch('/custom/launcher/api.php?session=1', { credentials: 'same-origin' })
|
||||
.then(res => res.ok ? res.json() : Promise.reject())
|
||||
.then(session => {
|
||||
@@ -2448,7 +2452,8 @@ function fetchDeviceData(includeLang = true, range = null) {
|
||||
return fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
'Content-Type': 'application/json',
|
||||
...(isStandalonePwa() ? { 'X-Custom-PWA': 'findmydevice' } : {})
|
||||
},
|
||||
credentials: 'same-origin',
|
||||
body: JSON.stringify({})
|
||||
@@ -2508,7 +2513,10 @@ function hasValidCoords(lat, lng) {
|
||||
function callDeviceWebhook(name, keepalive = false) {
|
||||
return fetch('https://chaegeon.com/custom/findmydevice/php/api.php?action=webhook', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...(isStandalonePwa() ? { 'X-Custom-PWA': 'findmydevice' } : {})
|
||||
},
|
||||
credentials: 'same-origin',
|
||||
keepalive,
|
||||
body: JSON.stringify({ name })
|
||||
|
||||
Reference in New Issue
Block a user