More improvements to the passcode lock process

This commit is contained in:
Scott Idem
2025-04-18 15:23:55 -04:00
parent 6d235d9159
commit 1828b0f141
2 changed files with 20 additions and 18 deletions

View File

@@ -20,15 +20,15 @@ import { events_loc } from '$lib/ae_events_stores';
// *** Setup Svelte properties // *** Setup Svelte properties
interface Props { interface Props {
log_lvl?: number; log_lvl?: number;
// data?: any;
show_passcode_input: boolean; show_passcode_input: boolean;
trigger_clear_access: null|boolean;
hidden: null|boolean; hidden: null|boolean;
} }
let { let {
log_lvl = 0, log_lvl = 0,
// data = null,
show_passcode_input = false, show_passcode_input = false,
trigger_clear_access = null,
hidden = true, hidden = true,
}: Props = $props(); }: Props = $props();
@@ -110,6 +110,7 @@ $effect(() => {
let access_checks_results = ae_util.process_permission_checks(''); let access_checks_results = ae_util.process_permission_checks('');
$ae_loc = {...$ae_loc, ...access_checks_results}; $ae_loc = {...$ae_loc, ...access_checks_results};
$ae_loc = $ae_loc;
} }
}); });
@@ -125,6 +126,16 @@ $effect(async () => {
} }
}); });
$effect(async () => {
if (trigger_clear_access) {
trigger_clear_access = false;
if (log_lvl) {
console.log(`trigger_clear_access=${trigger_clear_access}`);
}
handle_clear_access();
}
});
function handle_check_access_type_passcode() { function handle_check_access_type_passcode() {
if (log_lvl > 1) { if (log_lvl > 1) {
@@ -225,6 +236,7 @@ function handle_check_access_type_passcode() {
} }
function handle_clear_access() { function handle_clear_access() {
// console.log('handle_clear_access()');
// NOTE: I think it makes since to reset this to anonymous even if logged in as an admin or similar. // NOTE: I think it makes since to reset this to anonymous even if logged in as an admin or similar.
window.localStorage.setItem('access_type', 'anonymous'); window.localStorage.setItem('access_type', 'anonymous');
@@ -409,7 +421,8 @@ function handle_clear_access() {
<button <button
type="button" type="button"
onclick={() => { onclick={() => {
handle_clear_access(); // handle_clear_access();
trigger_clear_access = true;
}} }}
class="btn btn-sm variant-outline-surface hover:variant-ghost-warning transition-all" class="btn btn-sm variant-outline-surface hover:variant-ghost-warning transition-all"
title="Access mode is currently enabled/unlocked. Click to exit and lock." title="Access mode is currently enabled/unlocked. Click to exit and lock."

View File

@@ -75,6 +75,7 @@ if (log_lvl > 1) {
console.log(`ae_root +layout.svelte data:`, data); console.log(`ae_root +layout.svelte data:`, data);
} }
let trigger_clear_access: null|boolean = $state(null);
// let account_id = localStorage.getItem('ae_account_id'); // let account_id = localStorage.getItem('ae_account_id');
// console.log(`account_id = `, account_id); // console.log(`account_id = `, account_id);
@@ -514,19 +515,6 @@ $effect(() => {
} }
}); });
// function handle_clear_access() {
// // NOTE: I think it makes since to reset this to anonymous even if logged in as an admin or similar.
// window.localStorage.setItem('access_type', 'anonymous');
// // $ae_loc.access_type = null; // 'anonymous';
// $ae_loc.access_type = 'anonymous';
// trigger = 'process_permission_check';
// $ae_loc.app_cfg.show_element__passcode_input = false;
// return true;
// }
</script> </script>
{#if $ae_loc?.site_google_tracking_id && $ae_loc?.site_google_tracking_id.length > 0} {#if $ae_loc?.site_google_tracking_id && $ae_loc?.site_google_tracking_id.length > 0}
@@ -757,12 +745,12 @@ max-w-max -->
<button <button
type="button" type="button"
onclick={() => { onclick={() => {
// handle_clear_access(); trigger_clear_access = true;
if ($ae_loc?.app_cfg?.show_element__menu_btn) { if ($ae_loc?.app_cfg?.show_element__menu_btn) {
$ae_loc.app_cfg.show_element__menu = true; $ae_loc.app_cfg.show_element__menu = true;
$ae_loc.app_cfg.show_element__menu_btn = false; $ae_loc.app_cfg.show_element__menu_btn = false;
$ae_loc.app_cfg.show_element__access_type = false; $ae_loc.app_cfg.show_element__access_type = true;
} else { } else {
$ae_loc.app_cfg.show_element__menu = false; $ae_loc.app_cfg.show_element__menu = false;
$ae_loc.app_cfg.show_element__menu_btn = true; $ae_loc.app_cfg.show_element__menu_btn = true;
@@ -891,6 +879,7 @@ max-w-max -->
{#if $ae_loc.app_cfg?.show_element__access_type} {#if $ae_loc.app_cfg?.show_element__access_type}
<Element_access_type <Element_access_type
show_passcode_input={$ae_loc.app_cfg.show_element__passcode_input} show_passcode_input={$ae_loc.app_cfg.show_element__passcode_input}
trigger_clear_access={trigger_clear_access}
hidden={$ae_loc.iframe && !$ae_loc.trusted_access} hidden={$ae_loc.iframe && !$ae_loc.trusted_access}
/> />
{/if} {/if}