const form = document.querySelector('.tab-content.id form') if (form) { form.addEventListener('submit', async (e) => { e.preventDefault() const id = document.getElementById('login_id').value.trim() const pw = document.getElementById('login_password').value.trim() if (!id || !pw) { alert('아이디와 비밀번호를 입력하세요.') return } try { const res = await fetch('/kngil/bbs/login.php', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id, pw }) }) console.log('login.js loaded') const json = await res.json() if (json.status === 'success') { console.log('LOGIN OK, reload') document.getElementById('pop_login').style.display = 'none' location.reload() } else { alert(json.message) } } catch (err) { console.error(err) alert('로그인 중 오류가 발생했습니다.') } }) } // 팝업으로부터의 메시지 수신 (로그인 성공 시 새로고침) window.addEventListener('message', (event) => { // 보안을 위해 실제 서비스에서는 event.origin을 체크하는 것이 좋습니다. // if (event.origin !== location.origin) return; if (event.data && event.data.type === 'OIDC_LOGIN_SUCCESS') { location.reload(); } });