More work on authentication for staff and against the Novi UUIDs.
This commit is contained in:
@@ -58,7 +58,6 @@ import Analytics from '$lib/analytics.svelte'
|
||||
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
|
||||
import { events_loc, events_slct } from '$lib/ae_events_stores';
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
// console.log($ae_loc, $ae_sess, $ae_api);
|
||||
|
||||
import Element_access_type from '$lib/element_access_type.svelte';
|
||||
import Element_app_cfg from '$lib/element_app_cfg.svelte';
|
||||
@@ -99,70 +98,6 @@ $slct = {
|
||||
// IDB caches - Check if the last reload timestamp for $ae_loc.last_idb_reload is no more than 15 minutes ago.
|
||||
let default_idb_reload_time = 120 * 60 * 1000; // 15 minutes?
|
||||
let trusted_idb_reload_time = 4 * 60 * 60 * 1000; // 4 hours or 120 minutes?
|
||||
// if (!$ae_loc.last_idb_reload) {
|
||||
// console.log(`Last reload not found. Need to reset.`);
|
||||
|
||||
// // $ae_loc.last_idb_reload = Date.now();
|
||||
// if (browser) {
|
||||
// $ae_loc.last_idb_reload = Date.now();
|
||||
|
||||
// // Clear Indexed DB as well
|
||||
// indexedDB.deleteDatabase('ae_archives_db');
|
||||
// indexedDB.deleteDatabase('ae_core_db');
|
||||
// indexedDB.deleteDatabase('ae_events_db');
|
||||
// indexedDB.deleteDatabase('ae_notes_db');
|
||||
// indexedDB.deleteDatabase('ae_posts_db');
|
||||
|
||||
// // localStorage.removeItem('ae_loc');
|
||||
// // localStorage.removeItem('events_loc');
|
||||
|
||||
// // window.location.reload();
|
||||
// }
|
||||
|
||||
// } else if ($ae_loc.last_idb_reload && $ae_loc.trusted_access && (Date.now() - $ae_loc.last_idb_reload) > trusted_idb_reload_time) {
|
||||
// console.log(`Last reload too old:`, $ae_loc.last_idb_reload);
|
||||
|
||||
// if (browser) {
|
||||
// $ae_loc.last_idb_reload = Date.now();
|
||||
|
||||
// // Clear Indexed DB as well
|
||||
// indexedDB.deleteDatabase('ae_archives_db');
|
||||
// indexedDB.deleteDatabase('ae_core_db');
|
||||
// indexedDB.deleteDatabase('ae_events_db');
|
||||
// indexedDB.deleteDatabase('ae_notes_db');
|
||||
// indexedDB.deleteDatabase('ae_posts_db');
|
||||
|
||||
// // localStorage.removeItem('ae_loc');
|
||||
// // localStorage.removeItem('events_loc');
|
||||
|
||||
// window.location.reload();
|
||||
// }
|
||||
// } else if ($ae_loc.last_idb_reload && (Date.now() - $ae_loc.last_idb_reload) > default_idb_reload_time) {
|
||||
// console.log(`Last reload too old:`, $ae_loc.last_idb_reload);
|
||||
|
||||
// if (browser) {
|
||||
// $ae_loc.last_idb_reload = Date.now();
|
||||
|
||||
// // Clear Indexed DB as well
|
||||
// indexedDB.deleteDatabase('ae_core_db');
|
||||
// indexedDB.deleteDatabase('ae_events_db');
|
||||
|
||||
// // localStorage.removeItem('ae_loc');
|
||||
// // localStorage.removeItem('events_loc');
|
||||
|
||||
// window.location.reload();
|
||||
// }
|
||||
// } else if (browser) {
|
||||
// console.log(`Last reload is recent: ${$ae_loc.last_idb_reload}`);
|
||||
// // Clear Indexed DB as well
|
||||
// // indexedDB.deleteDatabase('ae_core_db');
|
||||
// // indexedDB.deleteDatabase('ae_events_db');
|
||||
|
||||
// // localStorage.removeItem('ae_loc');
|
||||
// // localStorage.removeItem('events_loc');
|
||||
|
||||
// // window.location.reload();
|
||||
// }
|
||||
|
||||
// There should almost always be an event_id set.
|
||||
if ($ae_loc?.site_cfg_json.slct__event_id) {
|
||||
|
||||
@@ -32,6 +32,7 @@ if (browser) {
|
||||
|
||||
// Reminder: super > manager > administrator > trusted > public > authenticated > anonymous
|
||||
|
||||
// NOTE: This is checking if they are in an iframe *and* have a Novi UUID. We ignore the iframe mode for trusted and above (administrators, managers, etc).
|
||||
if ($ae_loc.iframe && $idaa_loc?.novi_uuid?.length == 36 && $idaa_loc?.novi_email?.length > 3 && $idaa_loc?.novi_full_name?.length > 0) {
|
||||
$ae_loc.access_type = 'authenticated';
|
||||
$ae_loc.authenticated_access = true;
|
||||
|
||||
@@ -49,7 +49,7 @@ if (log_lvl) console.log('** Component Loaded: ** Post Options');
|
||||
</select>
|
||||
</span>
|
||||
|
||||
{#if $ae_loc.trusted_access && !$idaa_loc.bb.qry__hidden || $idaa_loc.bb.qry__hidden == 'not_hidden'}
|
||||
{#if $ae_loc.trusted_access && (!$idaa_loc.bb.qry__hidden || $idaa_loc.bb.qry__hidden == 'not_hidden')}
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
@@ -74,7 +74,7 @@ if (log_lvl) console.log('** Component Loaded: ** Post Options');
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
{#if $ae_loc.administrator_access && !$idaa_loc.bb.qry__enabled || $idaa_loc.bb.qry__enabled == 'enabled'}
|
||||
{#if $ae_loc.administrator_access && (!$idaa_loc.bb.qry__enabled || $idaa_loc.bb.qry__enabled == 'enabled')}
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => {
|
||||
|
||||
@@ -23,7 +23,7 @@ let novi_api_key_for_idaa = 'CmNdWgdPmgluBWjiTd8xsUCk5mio8F1O9DYAh0pVDcg=';
|
||||
let novi_current_user_obj = null;
|
||||
let novi_current_user_email = null;
|
||||
|
||||
let idaa_osit_site_key = 'restricted';
|
||||
let idaa_osit_site_key = 'restricted-access';
|
||||
let idaa_ae_api_root_url = 'https://dev-idaa.oneskyit.com/idaa/archives';
|
||||
let idaa_ae_params = new URLSearchParams(document.location.search);
|
||||
let idaa_ae_slct_archive_id = idaa_ae_params.get('archive_id');
|
||||
@@ -47,30 +47,32 @@ fetch(novi_api_get_customer_endpoint, requestOptions)
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
novi_current_user_obj = result;
|
||||
console.log(`Novi's Current User Obj (${novi_current_user_obj.Email}):`, novi_current_user_obj);
|
||||
// console.log(`Novi's Current User Obj (${novi_current_user_obj.Email}):`, novi_current_user_obj);
|
||||
|
||||
let idaa_ae_iframe_element = document.getElementById('ae_idaa_archives_iframe');
|
||||
|
||||
if (idaa_ae_slct_archive_id) {
|
||||
console.log(`Loading AE Archive ID: ${idaa_ae_slct_archive_id}`);
|
||||
// idaa_ae_iframe_element.src = `${idaa_ae_api_root_url}?uuid=${novi_customer_uid}&email=${novi_current_user_obj.Email}&archive_id=${idaa_ae_slct_archive_id}&full_name=${novi_current_user_obj.Name}&iframe=true`;
|
||||
// console.log(`Loading AE Archive ID: ${idaa_ae_slct_archive_id}`);
|
||||
idaa_ae_iframe_element.src = `${idaa_ae_api_root_url}/${idaa_ae_slct_archive_id}?uuid=${novi_customer_uid}&email=${novi_current_user_obj.Email}&full_name=${novi_current_user_obj.Name}&iframe=true&key=${idaa_osit_site_key}`;
|
||||
} else {
|
||||
idaa_ae_iframe_element.src = `${idaa_ae_api_root_url}?uuid=${novi_customer_uid}&email=${novi_current_user_obj.Email}&full_name=${novi_current_user_obj.Name}&iframe=true&key=${idaa_osit_site_key}`;
|
||||
|
||||
url.searchParams.delete('archive_id');
|
||||
history.pushState({}, '', url);
|
||||
}
|
||||
|
||||
let iframe_src = document.getElementById('iframe_src');
|
||||
iframe_src.innerHTML = `iframe src = ${idaa_ae_iframe_element.src}`;
|
||||
// let iframe_src = document.getElementById('iframe_src');
|
||||
// iframe_src.innerHTML = `iframe src = ${idaa_ae_iframe_element.src}`;
|
||||
})
|
||||
.catch(error => console.log('error', error));
|
||||
|
||||
window.addEventListener('message', function(event) {
|
||||
console.log('Message received from the child:', event.data); // Message received from child
|
||||
// console.log('Message received from the child:', event.data); // Message received from child
|
||||
|
||||
if (event.data) {
|
||||
if (event.data.iframe_height) {
|
||||
idaa_ae_iframe_height = event.data.iframe_height;
|
||||
console.log(`Got iframe height: ${idaa_ae_iframe_height}`);
|
||||
// console.log(`Got iframe height: ${idaa_ae_iframe_height}`);
|
||||
|
||||
let idaa_ae_iframe_element = document.getElementById('ae_idaa_archives_iframe');
|
||||
|
||||
@@ -112,7 +114,7 @@ window.addEventListener('message', function(event) {
|
||||
</script>
|
||||
|
||||
|
||||
<div id="iframe_src">iframe src=</div>
|
||||
<!-- <div id="iframe_src">iframe src=</div> -->
|
||||
|
||||
<!-- IDAA Aether Apps for Novi - Archives iframe -->
|
||||
<p><iframe width="100%" height="750" id="ae_idaa_archives_iframe" src="" style="min-height: 600px; max-height: 100%;" class="ae_idaa_iframe"></iframe></p>
|
||||
|
||||
@@ -23,6 +23,7 @@ let novi_api_key_for_idaa = 'CmNdWgdPmgluBWjiTd8xsUCk5mio8F1O9DYAh0pVDcg=';
|
||||
let novi_current_user_obj = null;
|
||||
let novi_current_user_email = null;
|
||||
|
||||
let idaa_osit_site_key = 'restricted-access';
|
||||
let idaa_ae_api_root_url = 'https://dev-idaa.oneskyit.com/idaa/bb';
|
||||
let idaa_ae_params = new URLSearchParams(document.location.search);
|
||||
let idaa_ae_slct_post_id = idaa_ae_params.get('post_id');
|
||||
@@ -39,32 +40,39 @@ var requestOptions = {
|
||||
};
|
||||
|
||||
let novi_api_get_customer_endpoint = `${novi_api_root_url}/customers/${novi_customer_uid}`;
|
||||
console.log(novi_api_get_customer_endpoint);
|
||||
// console.log(novi_api_get_customer_endpoint);
|
||||
|
||||
fetch(novi_api_get_customer_endpoint, requestOptions)
|
||||
// .then(response => response.text())
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
novi_current_user_obj = result;
|
||||
console.log(`Novi's Current User Obj (${novi_current_user_obj.Email}):`, novi_current_user_obj);
|
||||
// console.log(`Novi's Current User Obj (${novi_current_user_obj.Email}):`, novi_current_user_obj);
|
||||
|
||||
let idaa_ae_iframe_element = document.getElementById('ae_idaa_bb_iframe');
|
||||
|
||||
if (idaa_ae_slct_post_id) {
|
||||
idaa_ae_iframe_element.src = `${idaa_ae_api_root_url}?uuid=${novi_customer_uid}&email=${novi_current_user_obj.Email}&post_id=${idaa_ae_slct_post_id}&full_name=${novi_current_user_obj.Name}&iframe=true`;
|
||||
// console.log(`Loading AE Post ID: ${idaa_ae_slct_post_id}`);
|
||||
idaa_ae_iframe_element.src = `${idaa_ae_api_root_url}?uuid=${novi_customer_uid}&email=${novi_current_user_obj.Email}&full_name=${novi_current_user_obj.Name}&post_id=${idaa_ae_slct_post_id}&iframe=true&key=${idaa_osit_site_key}`;
|
||||
} else {
|
||||
idaa_ae_iframe_element.src = `${idaa_ae_api_root_url}?uuid=${novi_customer_uid}&email=${novi_current_user_obj.Email}&full_name=${novi_current_user_obj.Name}&iframe=true`;
|
||||
idaa_ae_iframe_element.src = `${idaa_ae_api_root_url}?uuid=${novi_customer_uid}&email=${novi_current_user_obj.Email}&full_name=${novi_current_user_obj.Name}&iframe=true&key=${idaa_osit_site_key}`;
|
||||
|
||||
url.searchParams.delete('post_id');
|
||||
history.pushState({}, '', url);
|
||||
}
|
||||
|
||||
// let iframe_src = document.getElementById('iframe_src');
|
||||
// iframe_src.innerHTML = `iframe src = ${idaa_ae_iframe_element.src}`;
|
||||
})
|
||||
.catch(error => console.log('error', error));
|
||||
|
||||
window.addEventListener('message', function(event) {
|
||||
console.log('Message received from the child:', event.data); // Message received from child
|
||||
// console.log('Message received from the child:', event.data); // Message received from child
|
||||
|
||||
if (event.data) {
|
||||
if (event.data.iframe_height) {
|
||||
idaa_ae_iframe_height = event.data.iframe_height;
|
||||
console.log(`Got iframe height: ${idaa_ae_iframe_height}`);
|
||||
// console.log(`Got iframe height: ${idaa_ae_iframe_height}`);
|
||||
|
||||
let idaa_ae_iframe_element = document.getElementById('ae_idaa_bb_iframe');
|
||||
|
||||
@@ -105,6 +113,9 @@ window.addEventListener('message', function(event) {
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<!-- <div id="iframe_src">iframe src=</div> -->
|
||||
|
||||
<!-- IDAA Aether Apps for Novi - Bulletin Board (posts) iframe -->
|
||||
<p><iframe width="100%" height="750" id="ae_idaa_bb_iframe" src="" style="min-height: 600px; max-height: 100%;" class="ae_idaa_iframe"></iframe></p>
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ let novi_api_key_for_idaa = 'CmNdWgdPmgluBWjiTd8xsUCk5mio8F1O9DYAh0pVDcg=';
|
||||
let novi_current_user_obj = null;
|
||||
let novi_current_user_email = null;
|
||||
|
||||
let idaa_osit_site_key = 'restricted-access';
|
||||
let idaa_ae_api_root_url = 'https://dev-idaa.oneskyit.com/idaa/recovery_meetings';
|
||||
let idaa_ae_params = new URLSearchParams(document.location.search);
|
||||
let idaa_ae_slct_event_id = idaa_ae_params.get('event_id');
|
||||
@@ -46,25 +47,32 @@ fetch(novi_api_get_customer_endpoint, requestOptions)
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
novi_current_user_obj = result;
|
||||
console.log(`Novi's Current User Obj (${novi_current_user_obj.Email}):`, novi_current_user_obj);
|
||||
// console.log(`Novi's Current User Obj (${novi_current_user_obj.Email}):`, novi_current_user_obj);
|
||||
|
||||
let idaa_ae_iframe_element = document.getElementById('ae_idaa_recovery_meetings_iframe');
|
||||
|
||||
if (idaa_ae_slct_event_id) {
|
||||
idaa_ae_iframe_element.src = `${idaa_ae_api_root_url}?uuid=${novi_customer_uid}&email=${novi_current_user_obj.Email}&event_id=${idaa_ae_slct_event_id}&full_name=${novi_current_user_obj.Name}&iframe=true`;
|
||||
// console.log(`Loading AE Archive ID: ${idaa_ae_slct_event_id}`);
|
||||
idaa_ae_iframe_element.src = `${idaa_ae_api_root_url}?uuid=${novi_customer_uid}&email=${novi_current_user_obj.Email}&full_name=${novi_current_user_obj.Name}&event_id=${idaa_ae_slct_event_id}&iframe=true&key=${idaa_osit_site_key}`;
|
||||
} else {
|
||||
idaa_ae_iframe_element.src = `${idaa_ae_api_root_url}?uuid=${novi_customer_uid}&email=${novi_current_user_obj.Email}&full_name=${novi_current_user_obj.Name}&iframe=true`;
|
||||
idaa_ae_iframe_element.src = `${idaa_ae_api_root_url}?uuid=${novi_customer_uid}&email=${novi_current_user_obj.Email}&full_name=${novi_current_user_obj.Name}&iframe=true&key=${idaa_osit_site_key}`;
|
||||
|
||||
url.searchParams.delete('event_id');
|
||||
history.pushState({}, '', url);
|
||||
}
|
||||
|
||||
// let iframe_src = document.getElementById('iframe_src');
|
||||
// iframe_src.innerHTML = `iframe src = ${idaa_ae_iframe_element.src}`;
|
||||
})
|
||||
.catch(error => console.log('error', error));
|
||||
|
||||
window.addEventListener('message', function(event) {
|
||||
console.log('Message received from the child:', event.data); // Message received from child
|
||||
// console.log('Message received from the child:', event.data); // Message received from child
|
||||
|
||||
if (event.data) {
|
||||
if (event.data.iframe_height) {
|
||||
idaa_ae_iframe_height = event.data.iframe_height;
|
||||
console.log(`Got iframe height: ${idaa_ae_iframe_height}`);
|
||||
// console.log(`Got iframe height: ${idaa_ae_iframe_height}`);
|
||||
|
||||
let idaa_ae_iframe_element = document.getElementById('ae_idaa_recovery_meetings_iframe');
|
||||
|
||||
@@ -105,6 +113,9 @@ window.addEventListener('message', function(event) {
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<!-- <div id="iframe_src">iframe src=</div> -->
|
||||
|
||||
<!-- IDAA Aether Apps for Novi - Recovery Meetings (events) iframe -->
|
||||
<p><iframe width="100%" height="750" id="ae_idaa_recovery_meetings_iframe" src="" style="min-height: 600px; max-height: 100%;" class="ae_idaa_iframe"></iframe></p>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user