diff --git a/src/lib/ae_stores.ts b/src/lib/ae_stores.ts index 03f189be..944ba935 100644 --- a/src/lib/ae_stores.ts +++ b/src/lib/ae_stores.ts @@ -67,7 +67,7 @@ export let ae_app_local_data_struct: key_val = { 'account_id': ae_account_id, // OSIT Demo _XY7DXtc9MY 'account_code': 'not_set', 'account_name': 'Account Name Not Set', - 'allow_access': false, // Set to key if access is allowed. + 'allow_access': true, // Set to key site key was used, otherwise set to true. 'site_domain': null, // https://example.com, https://dev.example.com, etc. 'site_access_key': null, // This is the general site access key 'site_domain_access_key': null, // This is specific to a (sub)domain. diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index b02f07cb..b27dafa5 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -190,46 +190,75 @@ if ($ae_loc.site_cfg_json.slct__sponsorship_cfg_id) { // This needs to be re-worked ASAP! 2024-11-21 -if ($ae_loc.iframe) { - $ae_loc.allow_access = true; -} else { +// Is most of this even needed? Just check every time. Why do we care if we checked recently or ever. +// Instead: Check if the access key is set and if it is the same as the site or domain access key. +// What happens if the access key is set and it is not the same as the site or domain access key? I guess the restriction was removed so it can be used without the key. - if ($ae_loc.allow_access && !$ae_loc.key_checked) { - console.log(`PASS: The access key was checked earlier.`); +if ($ae_loc.site_access_key || $ae_loc.site_domain_access_key) { + console.log(`We need to do a current check against the allow_access value.`); - // allow_access should equal true or the access key. - if ($ae_loc.site_access_key || $ae_loc.site_domain_access_key) { - console.log(`We need to do a current check against the allow_access value.`); - if ($ae_loc.site_access_key == $ae_loc.allow_access || $ae_loc.site_domain_access_key == $ae_loc.allow_access) { - console.log(`PASS: The access key was checked earlier and we just now checked the key.`); - } else { - console.log(`FAIL: The access key was checked earlier, but just now failed.`); - if ($ae_loc.trusted_access) { - console.log(`FAIL: The access key was checked earlier and failed, but we have trusted access.`); - $ae_loc.allow_access = true; - } else { - $ae_loc.allow_access = false; - } - } - } else { - // This means this site and domain do not require an access key. - // Do nothing to change the allow_access here at this time. - } - } else if ($ae_loc.allow_access && $ae_loc.key_checked) { + if ($ae_loc.site_access_key === $ae_loc.allow_access || $ae_loc.site_domain_access_key === $ae_loc.allow_access) { console.log(`PASS: The access key was checked earlier and we just now checked the key.`); - } else if (!$ae_loc.allow_access && $ae_loc.key_checked) { - console.log(`FAIL: The access key was checked earlier and failed.`); + } else { + console.log(`FAIL: The access key was checked earlier, but just now failed.`); if ($ae_loc.trusted_access) { console.log(`FAIL: The access key was checked earlier and failed, but we have trusted access.`); $ae_loc.allow_access = true; + } else { + $ae_loc.allow_access = false; } - } else { - console.log(`FAIL: The access key was not checked earlier.`); - // $ae_loc.key_checked = true; } - +} else { + // This means this site and domain do not require an access key. + $ae_loc.allow_access = true; } + + + + + + +// if ($ae_loc.iframe) { +// $ae_loc.allow_access = true; +// } else { + +// if ($ae_loc.allow_access && !$ae_loc.key_checked) { +// console.log(`PASS: The access key was checked earlier.`); + +// // allow_access should equal true or the access key. +// if ($ae_loc.site_access_key || $ae_loc.site_domain_access_key) { +// console.log(`We need to do a current check against the allow_access value.`); +// if ($ae_loc.site_access_key == $ae_loc.allow_access || $ae_loc.site_domain_access_key == $ae_loc.allow_access) { +// console.log(`PASS: The access key was checked earlier and we just now checked the key.`); +// } else { +// console.log(`FAIL: The access key was checked earlier, but just now failed.`); +// if ($ae_loc.trusted_access) { +// console.log(`FAIL: The access key was checked earlier and failed, but we have trusted access.`); +// $ae_loc.allow_access = true; +// } else { +// $ae_loc.allow_access = false; +// } +// } +// } else { +// // This means this site and domain do not require an access key. +// // Do nothing to change the allow_access here at this time. +// } +// } else if ($ae_loc.allow_access && $ae_loc.key_checked) { +// console.log(`PASS: The access key was checked earlier and we just now checked the key.`); +// } else if (!$ae_loc.allow_access && $ae_loc.key_checked) { +// console.log(`FAIL: The access key was checked earlier and failed.`); +// if ($ae_loc.trusted_access) { +// console.log(`FAIL: The access key was checked earlier and failed, but we have trusted access.`); +// $ae_loc.allow_access = true; +// } +// } else { +// console.log(`FAIL: The access key was not checked earlier.`); +// // $ae_loc.key_checked = true; +// } + +// } + // $: access_key = data.url.searchParams.get('key'); // console.log(`access_key = `, access_key); @@ -315,7 +344,6 @@ if (browser) { onMount(() => { console.log('Root: +layout.svelte'); - // Waiting until the browser exists. // save_ds_to_local(ae_acct.ds); // $ae_sess.site_appshell_header = JSON.parse(localStorage.getItem('ae_ds__hub__site__appshell_header')); @@ -325,21 +353,20 @@ onMount(() => { let iframe = data.url.searchParams.get('iframe'); if (iframe == 'true') { console.log('Use iframe layout!'); - // data_struct['iframe'] = iframe; $ae_loc.iframe = true; document.getElementsByTagName('html')[0].classList.add('iframe'); - document.getElementsByTagName('html')[0].classList.remove('dark'); - document.getElementsByTagName('html')[0].classList.remove('light'); + // document.getElementsByTagName('html')[0].classList.remove('dark'); + // document.getElementsByTagName('html')[0].classList.remove('light'); $ae_loc.hub.show_element__access_type = false; $ae_loc.hub.show_element__cfg = false; } else if (iframe == 'false') { - // data_struct['iframe'] = false; $ae_loc.iframe = false; document.getElementsByTagName('html')[0].classList.remove('iframe'); - document.getElementsByTagName('html')[0].classList.add('light'); + // document.getElementsByTagName('html')[0].classList.add('light'); + // document.getElementsByTagName('html')[0].classList.add('dark'); } if (!$ae_loc.iframe && $ae_loc.trusted_access) { @@ -364,17 +391,6 @@ onMount(() => { } - // TESTING TESTING TESTING - // WARNING: This needs to be tied to an object type and ID. This is a temporary solution. - // $ae_sess.download = { - // 'endpoint': '/event/file/abc123/download', - // 'filename': 'example.txt', - // 'size_total': 0, - // 'size_loaded': 0, - // 'percent_completed': 0, - // }; - - // This is how the download and upload progress is tracked. window.addEventListener('message', function(event) { if (log_lvl) { @@ -389,16 +405,6 @@ onMount(() => { let task_id = event.data.task_id; - // $ae_sess.download[event.data.endpoint] = { - // 'status': event.data.status, - // 'task_id': task_id, - // 'endpoint': event.data.endpoint, - // 'filename': event.data.filename, - // 'size_total': event.data.size_total, - // 'size_loaded': event.data.size_loaded, - // 'percent_completed': event.data.percent_completed, - // }; - $ae_sess.api_download_kv[task_id] = { 'status': event.data.status, @@ -430,9 +436,6 @@ onMount(() => { }; } }); - - // console.log(`access_key = `, access_key); - }); @@ -451,7 +454,7 @@ onMount(() => { {#if - $ae_loc.allow_access} + $ae_loc?.allow_access} {

Access Denied

-

You do not have access to this site.

+

You do not have access to this site. You may need a passcode and or URL site key.