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

View File

@@ -23,81 +23,88 @@ onMount(() => {
<section
class="ae_root md:container h-full mx-auto flex flex-col items-center p-4 space-y-12"
class:ae_root--auth_access={$ae_loc.auth_access}
class:ae_root--public_access={$ae_loc.public_access}
class:ae_root--trusted_access={$ae_loc.trusted_access}
class:ae_root--administrator_access={$ae_loc.administrator_access}
class:ae_root--manager_access={$ae_loc.manager_access}
class:ae_root--super_access={$ae_loc.super_access}
>
class="ae_root md:container h-full mx-auto flex flex-col items-center p-4 space-y-12"
class:ae_root--auth_access={$ae_loc.auth_access}
class:ae_root--public_access={$ae_loc.public_access}
class:ae_root--trusted_access={$ae_loc.trusted_access}
class:ae_root--administrator_access={$ae_loc.administrator_access}
class:ae_root--manager_access={$ae_loc.manager_access}
class:ae_root--super_access={$ae_loc.super_access}
>
<Element_data_store
ds_code="hub__site__root_page_header"
ds_type="html"
for_type={null}
for_id={null}
ds_name="Default: AE Hub - Site root page header HTML"
class_li={$ae_sess.ds_loaded.hub__site__root_page_header === false ? 'hidden' : ''}
bind:ds_loaded={$ae_sess.ds_loaded.hub__site__root_page_header}
/>
ds_code="hub__site__root_page_header"
ds_type="html"
for_type={null}
for_id={null}
ds_name="Default: AE Hub - Site root page header HTML"
class_li={$ae_sess.ds_loaded.hub__site__root_page_header === false ? 'hidden' : ''}
bind:ds_loaded={$ae_sess.ds_loaded.hub__site__root_page_header}
/>
<!-- page header DS: {$ae_sess.ds_loaded.hub__site__root_page_header} -->
<Element_data_store
ds_code="hub__site__root_page_content"
ds_type="html"
for_type={null}
for_id={null}
ds_name="Default: AE Hub - Site root page content HTML"
show_edit={false}
class_li={$ae_sess.ds_loaded.hub__site__root_page_content === false ? 'hidden' : 'grow'}
bind:ds_loaded={$ae_sess.ds_loaded.hub__site__root_page_content}
/>
ds_code="hub__site__root_page_content"
ds_type="html"
for_type={null}
for_id={null}
ds_name="Default: AE Hub - Site root page content HTML"
show_edit={false}
class_li={$ae_sess.ds_loaded.hub__site__root_page_content === false ? 'hidden' : 'grow'}
bind:ds_loaded={$ae_sess.ds_loaded.hub__site__root_page_content}
/>
<!-- page content DS: {$ae_sess.ds_loaded.hub__site__root_page_content} -->
<section class="flex flex-col gap-2 items-center p-4 space-y-6">
<div data-sveltekit-preload-data="false" class="">
<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={() => {
window.location.reload(true);
}}
>
<span class="fas fa-sync mx-1"></span>
Reload and Clear Cache
</button>
<button
class="btn btn-sm m-1 variant-glass-surface hover:variant-outline-warning text-error-300 hover:text-error-800"
title="Clear the browser storage for this page"
on:click={() => {
localStorage.clear();
sessionStorage.clear();
alert('Local and Session Storage cleared. You will probably want to refresh the page.');
}}
>
<span class="fas fa-sync mx-1"></span>
Clear Storage
</button>
</div>
<div
data-sveltekit-preload-data="false"
class="flex flex-row flex-wrap items-center justify-center"
>
<button
type="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={() => {
window.location.reload(true);
}}
>
<span class="fas fa-sync mx-1"></span>
Reload
</button>
<button
type="button"
class="btn btn-sm m-1 p-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>
Clear Storage and Reload
</button>
</div>
<Element_data_store
expire_minutes={2}
ds_code="hub__site__root_page_footer"
ds_type="html"
for_type={null}
for_id={null}
ds_name="Default: AE Hub - Site root page footer HTML"
display="block"
class_li={!$ae_loc.manager_access && $ae_sess.ds_loaded.hub__site__root_page_footer === false ? 'hidden' : ''}
bind:ds_loaded={$ae_sess.ds_loaded.hub__site__root_page_footer}
/>
<!-- page footer DS: {$ae_sess.ds_loaded.hub__site__root_page_footer} -->
<Element_data_store
expire_minutes={2}
ds_code="hub__site__root_page_footer"
ds_type="html"
for_type={null}
for_id={null}
ds_name="Default: AE Hub - Site root page footer HTML"
display="block"
class_li={!$ae_loc.manager_access && $ae_sess.ds_loaded.hub__site__root_page_footer === false ? 'hidden' : ''}
bind:ds_loaded={$ae_sess.ds_loaded.hub__site__root_page_footer}
/>
<!-- page footer DS: {$ae_sess.ds_loaded.hub__site__root_page_footer} -->
<ol class="list-decimal hidden">
<li>Placeholder for Tailwind</li>
</ol>
<ol class="list-decimal hidden">
<li>Placeholder for Tailwind</li>
</ol>
</section>

View File

@@ -141,23 +141,50 @@ $: if ($ae_loc.iframe && $ae_loc.iframe_height && $ae_loc.iframe_height_modal_bo
</svelte:head>
{#if ($ae_loc.authenticated_access)}
<div
bind:clientHeight={$ae_loc.iframe_height}
>
<slot />
</div>
{:else}
<div class="container flex flex-col gap-1 w-full items-center justify-center font-bold p-8 m-8">
<h1>
<span class="text-red-500">
<span class="fas fa-exclamation-triangle"></span>
Access Denied
<span class="fas fa-exclamation-triangle"></span>
{#if ($ae_loc.trusted_access || ($ae_loc.authenticated_access && $idaa_loc.novi_uuid))}
<div
bind:clientHeight={$ae_loc.iframe_height}
>
<slot />
</div>
{#if $idaa_loc.novi_uuid}
<span class="text-sm text-gray-500">
Novi: <span class="fas fa-user m-1"></span>
{$idaa_loc.novi_uuid}
{$idaa_loc.novi_full_name ?? 'name not set'}
{$idaa_loc.novi_email ?? 'email not set'}
</span>
</h1>
<p>You do not have access to this page.</p>
</div>
{:else}
<p class="text-sm text-gray-500 text-center">IDAA Novi UUID not found!</p>
{/if}
{:else}
<div class="container flex flex-col gap-1 w-full items-center justify-center font-bold p-8 m-8">
<h1>
<span class="text-red-500">
<span class="fas fa-exclamation-triangle"></span>
Access Denied
<span class="fas fa-exclamation-triangle"></span>
</span>
</h1>
<p>You do not have access to these IDAA page.</p>
{#if $ae_loc.iframe}
In iframe mode
{/if}
{#if $idaa_loc.novi_uuid}
<span class="text-sm text-gray-500">
Novi: <span class="fas fa-user m-1"></span>
{$idaa_loc.novi_uuid}
{$idaa_loc.novi_full_name ?? 'name not set'}
{$idaa_loc.novi_email ?? 'email not set'}
</span>
{:else}
<p>IDAA Novi UUID not found!</p>
{/if}
</div>
{/if}