10 lines
1 KiB
JavaScript
10 lines
1 KiB
JavaScript
// Dedicated clan workspace: imports the existing functional clan client, never the CP shell.
|
|
const status=document.querySelector('#clan-center-access');
|
|
try{
|
|
const response=await fetch('/api/auth/session',{credentials:'same-origin',cache:'no-store',signal:AbortSignal.timeout(15000)}),session=await response.json();
|
|
if(!response.ok||!session.authenticated)throw Error('Sign in to open your Clan Center.');
|
|
if(!session.user?.permissions?.includes('web.menu.game'))throw Error('Your account does not have access to the Clan Center.');
|
|
if(!location.hash)history.replaceState(null,'','#clans');
|
|
try{if(parent!==window&&new URL(document.referrer).origin===location.origin)document.body.classList.add('clan-cp-embedded');}catch{}
|
|
await import('./clans.mjs');status.remove();
|
|
}catch(error){status.replaceChildren(document.createTextNode(error.message+' '));const login=document.createElement('a');login.href='https://cp.dunerealms.com/';login.target='_top';login.textContent='Open account sign-in →';status.append(login);}
|

Staff