common.js 로그인 반영 개선
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
// /kngil/auth/oidc-login.php
|
||||
require_once dirname(__DIR__) . '/bbs/env.php';
|
||||
kngil_start_session();
|
||||
require_once dirname(__DIR__) . '/vendor/autoload.php';
|
||||
$config = require_once dirname(__DIR__) . '/bbs/oidc_config.php';
|
||||
|
||||
|
||||
@@ -4921,18 +4921,28 @@ var Swiper=function(){"use strict";function e(e){return null!==e&&"object"==type
|
||||
const buttons = document.querySelectorAll('[data-oidc-login]');
|
||||
if (!buttons.length) return;
|
||||
buttons.forEach((button) => {
|
||||
button.addEventListener('click', openOidcLogin);
|
||||
if (button.dataset.oidcBound === '1') return;
|
||||
button.dataset.oidcBound = '1';
|
||||
button.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
window.openOidcLogin();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
window.openOidcLogin = openOidcLogin;
|
||||
window.login = openOidcLogin;
|
||||
if (!window.openOidcLogin) {
|
||||
window.openOidcLogin = openOidcLogin;
|
||||
}
|
||||
window.login = window.openOidcLogin;
|
||||
|
||||
window.addEventListener('message', (event) => {
|
||||
if (event.data && event.data.type === 'OIDC_LOGIN_SUCCESS') {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
if (!window.__oidcLoginMessageBound) {
|
||||
window.addEventListener('message', (event) => {
|
||||
if (event.data && event.data.type === 'OIDC_LOGIN_SUCCESS') {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
window.__oidcLoginMessageBound = true;
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', bindOidcButtons);
|
||||
|
||||
@@ -24,7 +24,7 @@ if ($displayName === '') {
|
||||
}
|
||||
|
||||
// 권한 그룹
|
||||
$isSuperAdmin = in_array($auth, ['BS100100', 'BS100200']);
|
||||
$isSuperAdmin = in_array($auth, ['BS100100', 'BS100200']);
|
||||
$isCompanyAdmin = in_array($auth, ['BS100100', 'BS100200', 'BS100300', 'BS100400']);
|
||||
?>
|
||||
<head>
|
||||
@@ -144,6 +144,55 @@ $isCompanyAdmin = in_array($auth, ['BS100100', 'BS100200', 'BS100300', 'BS100400
|
||||
window.IS_LOGIN = <?= isset($_SESSION['login']) ? 'true' : 'false' ?>;
|
||||
window.IDP_SERVICE_URL = <?= json_encode($idpServiceUrl, JSON_UNESCAPED_SLASHES) ?>;
|
||||
</script>
|
||||
<script>
|
||||
(function () {
|
||||
function openOidcLoginPopup() {
|
||||
const width = 500;
|
||||
const height = 600;
|
||||
const left = (window.screen.width / 2) - (width / 2);
|
||||
const top = (window.screen.height / 2) - (height / 2);
|
||||
|
||||
window.open(
|
||||
'/kngil/auth/oidc-login.php',
|
||||
'oidc_login_popup',
|
||||
`width=${width},height=${height},left=${left},top=${top},scrollbars=yes`
|
||||
);
|
||||
}
|
||||
|
||||
if (!window.openOidcLogin) {
|
||||
window.openOidcLogin = openOidcLoginPopup;
|
||||
}
|
||||
window.login = window.openOidcLogin;
|
||||
|
||||
if (!window.__oidcLoginMessageBound) {
|
||||
window.addEventListener('message', function (event) {
|
||||
if (event.data && event.data.type === 'OIDC_LOGIN_SUCCESS') {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
window.__oidcLoginMessageBound = true;
|
||||
}
|
||||
|
||||
function bindOidcButtons() {
|
||||
const buttons = document.querySelectorAll('[data-oidc-login]');
|
||||
if (!buttons.length) return;
|
||||
buttons.forEach((button) => {
|
||||
if (button.dataset.oidcBound === '1') return;
|
||||
button.dataset.oidcBound = '1';
|
||||
button.addEventListener('click', function (event) {
|
||||
event.preventDefault();
|
||||
window.openOidcLogin();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', bindOidcButtons);
|
||||
} else {
|
||||
bindOidcButtons();
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<!-- header -->
|
||||
@@ -164,7 +213,7 @@ $isCompanyAdmin = in_array($auth, ['BS100100', 'BS100200', 'BS100300', 'BS100400
|
||||
</span>
|
||||
<a href="/kngil/bbs/logout.php" class="btn-logout-top">로그아웃</a>
|
||||
<?php else: ?>
|
||||
<button type="button" class="btn-oidc-top" data-oidc-login>[바론 통합로그인]</button>
|
||||
<button type="button" class="btn-oidc-top" data-oidc-login>[바론 로그인]</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user