BARON-SSO 로그인 연동
This commit is contained in:
@@ -55,7 +55,7 @@ $download_url = "https://release-download.hmac.kr/eg-bim/{$version}/setup_eg-bim
|
||||
<a href="javascript:descopeLogout();">로그아웃</a>
|
||||
</li>
|
||||
<li id="my_join" class="my_join">
|
||||
<a href="javascript:agreement();">회원가입</a>
|
||||
<a href="#" class="signup-disabled-link" aria-disabled="true">회원가입</a>
|
||||
</li>
|
||||
<li id="my_login" class="my_login">
|
||||
<a href="javascript:login();">로그인</a>
|
||||
@@ -94,9 +94,84 @@ $download_url = "https://release-download.hmac.kr/eg-bim/{$version}/setup_eg-bim
|
||||
// e.preventDefault(); // 링크 이동 막기
|
||||
// alert('다운로드 기능은 준비중입니다.');
|
||||
// });
|
||||
</script>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
function getCookieValue(name) {
|
||||
const prefix = name + '=';
|
||||
const parts = document.cookie.split(';');
|
||||
for (let i = 0; i < parts.length; i += 1) {
|
||||
const part = parts[i].trim();
|
||||
if (part.indexOf(prefix) === 0) {
|
||||
return part.substring(prefix.length);
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function decodeBase64Json(value) {
|
||||
if (!value) return null;
|
||||
|
||||
try {
|
||||
const binary = window.atob(value);
|
||||
const bytes = Array.prototype.map.call(binary, function (char) {
|
||||
return '%' + ('00' + char.charCodeAt(0).toString(16)).slice(-2);
|
||||
}).join('');
|
||||
return JSON.parse(decodeURIComponent(bytes));
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function setStoredValue(key, value) {
|
||||
if (typeof value === 'string' && value !== '') {
|
||||
sessionStorage.setItem(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
function restoreClientAuthSessionFromCookies() {
|
||||
const baronUser = decodeBase64Json(getCookieValue('baron_user'));
|
||||
|
||||
if (baronUser && Array.isArray(baronUser.loginIds) && baronUser.loginIds[0]) {
|
||||
const customAttributes = baronUser.customAttributes || {};
|
||||
const roleNames = Array.isArray(baronUser.roleNames) ? baronUser.roleNames : [];
|
||||
|
||||
setStoredValue('authProvider', 'baron');
|
||||
setStoredValue('loginId', baronUser.loginIds[0] || '');
|
||||
setStoredValue('descopeUserId', baronUser.userId || '');
|
||||
setStoredValue('userName', baronUser.name || '');
|
||||
setStoredValue('phone', baronUser.phone || '');
|
||||
setStoredValue('company', customAttributes.company || '');
|
||||
setStoredValue('familyCompany', customAttributes.familyCompany || '');
|
||||
setStoredValue('team', customAttributes.team || '');
|
||||
setStoredValue('position', customAttributes.position || '');
|
||||
setStoredValue('familyUniqueKey', customAttributes.familyUniqueKey || '');
|
||||
setStoredValue('userRole', roleNames[0] || '');
|
||||
setStoredValue('sessionJwt', sessionStorage.getItem('sessionJwt') || 'baron.session.marker');
|
||||
return;
|
||||
}
|
||||
|
||||
const descopeLoginId = getCookieValue('descope_login_id');
|
||||
if (descopeLoginId && !sessionStorage.getItem('loginId')) {
|
||||
const customAttributes = decodeBase64Json(getCookieValue('descope_custom_attributes')) || {};
|
||||
const roleNames = decodeBase64Json(getCookieValue('descope_role_names')) || [];
|
||||
|
||||
setStoredValue('authProvider', sessionStorage.getItem('authProvider') || 'descope');
|
||||
setStoredValue('loginId', descopeLoginId);
|
||||
setStoredValue('descopeUserId', getCookieValue('descope_user_id'));
|
||||
setStoredValue('userName', getCookieValue('descope_user_name'));
|
||||
setStoredValue('phone', getCookieValue('descope_user_phone'));
|
||||
setStoredValue('company', customAttributes.company || '');
|
||||
setStoredValue('familyCompany', customAttributes.familyCompany || '');
|
||||
setStoredValue('team', customAttributes.team || '');
|
||||
setStoredValue('position', customAttributes.position || '');
|
||||
setStoredValue('familyUniqueKey', customAttributes.familyUniqueKey || '');
|
||||
setStoredValue('userRole', Array.isArray(roleNames) ? (roleNames[0] || '') : '');
|
||||
}
|
||||
}
|
||||
|
||||
restoreClientAuthSessionFromCookies();
|
||||
})();
|
||||
|
||||
(function () {
|
||||
const ADMIN_ICON_IDS = [
|
||||
'b24014@hanmaceng.co.kr',
|
||||
@@ -181,6 +256,10 @@ $download_url = "https://release-download.hmac.kr/eg-bim/{$version}/setup_eg-bim
|
||||
}, 50);
|
||||
});
|
||||
|
||||
$(document).on('click', '.signup-disabled-link', function (e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
// 혹시 로그인 팝업을 다른 곳에서 열어도 배너가 필요하면, 팝업 열릴 때 한 번 더 시도
|
||||
$(document).on('show-login-popup', function () {
|
||||
injectBanner();
|
||||
|
||||
Reference in New Issue
Block a user