Re-work of site permissions and Novi permissions.

This commit is contained in:
Scott Idem
2024-11-21 14:19:08 -05:00
parent fcec4ed96f
commit cffde76c88
6 changed files with 197 additions and 127 deletions

View File

@@ -189,38 +189,45 @@ if ($ae_loc.site_cfg_json.slct__sponsorship_cfg_id) {
}
if ($ae_loc.allow_access && !$ae_loc.key_checked) {
console.log(`PASS: The access key was checked earlier.`);
// This needs to be re-worked ASAP! 2024-11-21
if ($ae_loc.iframe) {
$ae_loc.allow_access = true;
} else {
// 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;
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 {
$ae_loc.allow_access = false;
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 {
// This means this site and domain do not require an access key.
// Do nothing to change the allow_access here at this time.
console.log(`FAIL: The access key was not checked earlier.`);
// $ae_loc.key_checked = true;
}
} 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');
@@ -443,6 +450,9 @@ onMount(() => {
<!-- regionFooter="flex justify-end space-x-2" -->
{#if
$ae_loc.allow_access}
<Modal components={modalRegistry}
regionBackdrop=''
regionBody=''
@@ -495,8 +505,7 @@ onMount(() => {
<!-- !($ae_loc.site_access_key && $ae_loc.site_domain_access_key)
|| ($ae_loc.site_access_key == access_key || $ae_loc.site_domain_access_key == access_key)} -->
{#if
$ae_loc.allow_access}
<!-- {$ae_loc?.site_access_key ?? '-- site access key not set --'} -->
<!-- {$ae_loc?.site_domain_access_key ?? '-- site domain access key not set --'} -->
@@ -505,12 +514,6 @@ onMount(() => {
<!-- Page Route Content -->
<slot />
{:else}
<div class="flex flex-col items-center justify-center h-screen">
<h1 class="text-4xl font-bold text-red-500">Access Denied</h1>
<p class="text-lg text-gray-500">You do not have access to this site.</p>
</div>
{/if}
<svelte:fragment slot="footer">
@@ -542,6 +545,32 @@ onMount(() => {
</AppShell>
{:else}
<div
data-sveltekit-preload-data="false"
class="flex flex-col items-center justify-center h-full"
>
<h1 class="text-4xl font-bold text-red-500">Access Denied</h1>
<p class="text-lg text-gray-500">You do not have access to this site.</p>
<button
class="btn btn-sm m-1 variant-glass-surface hover:variant-outline-warning text-error-300 hover:text-error-800"
title="Reload and clear the page cache"
on:click={() => {
localStorage.clear();
sessionStorage.clear();
alert('Local and Session Storage cleared. The page should now refresh on its own.');
window.location.reload(true);
}}
>
<span class="fas fa-sync mx-1"></span>
Reload and Clear Cache
</button>
</div>
{/if}
{#if $ae_loc.hub?.show_element__access_type}
<Element_access_type