mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
16 lines
612 B
TypeScript
16 lines
612 B
TypeScript
export function addAutoLoginToAdminPanelButton() {
|
|
const adminPanelHost = new URL(window.location.href).host.split('.').slice(1).join('.');
|
|
|
|
document.body?.addEventListener('click', async (e) => {
|
|
if (!e.target || !(e.target instanceof Element)) return;
|
|
if (e.target.getAttribute('id') !== 'admin' && !e.target.closest('#admin')) return;
|
|
|
|
e.preventDefault();
|
|
|
|
const restPath = window.REST_ENDPOINT ?? 'rest';
|
|
const response = await fetch(`/${restPath}/cloud/proxy/login/code`);
|
|
const { code } = await response.json();
|
|
window.location.href = `https://${adminPanelHost}/login?code=${code}`;
|
|
});
|
|
}
|