Improved sign in process and UI

This commit is contained in:
Scott Idem
2025-04-09 12:09:41 -04:00
parent 0d8b47af10
commit 10c3e34b38
2 changed files with 31 additions and 5 deletions

View File

@@ -2,6 +2,7 @@
// *** Import Svelte specific // *** Import Svelte specific
import { browser } from '$app/environment'; import { browser } from '$app/environment';
import { goto } from '$app/navigation';
// *** Import other supporting libraries // *** Import other supporting libraries
import { import {
@@ -51,6 +52,7 @@ let user_obj: key_val = $state({}); // Use $state to ensure reactivity
let person_id = $state(null); // Use $state to ensure reactivity let person_id = $state(null); // Use $state to ensure reactivity
let person_obj: key_val = $state({}); // Use $state to ensure reactivity let person_obj: key_val = $state({}); // Use $state to ensure reactivity
$effect(() => { $effect(() => {
if (user_id && person_id && trigger) { if (user_id && person_id && trigger) {
// alert(`Ready to sign in person! \n\nuser_id: ${user_id}\nperson_id: ${person_id}\n\nThis is a test alert to confirm the values are set.`); // alert(`Ready to sign in person! \n\nuser_id: ${user_id}\nperson_id: ${person_id}\n\nThis is a test alert to confirm the values are set.`);
@@ -59,6 +61,7 @@ $effect(() => {
} }
}); });
function sign_in() { function sign_in() {
$ae_loc.person_id = person_id; // Set the person_id in the ae_loc store $ae_loc.person_id = person_id; // Set the person_id in the ae_loc store
$ae_loc.person = person_obj; // Store the full person object for reference $ae_loc.person = person_obj; // Store the full person object for reference
@@ -91,8 +94,21 @@ function sign_in() {
...access_checks_results ...access_checks_results
}; };
// $ae_loc = {...access_checks_results}; // $ae_loc = {...access_checks_results};
console.log('Remove the sign in fields from the URL.');
data.url.searchParams.delete('user_id');
data.url.searchParams.delete('user_key');
data.url.searchParams.delete('username');
data.url.searchParams.delete('user_email');
data.url.searchParams.delete('valid_email'); // Part of sign in email for possible future use
let new_url = data.url.toString();
// We need to set browser history and force all load functions to rerun.
goto(new_url, {replaceState: true, invalidateAll: true});
} }
function sign_out() { function sign_out() {
// Clear the session information // Clear the session information
$ae_loc.person_id = null; $ae_loc.person_id = null;
@@ -109,6 +125,11 @@ function sign_out() {
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_sess.auth__entered_user_id = null;
$ae_sess.auth__entered_user_key = null;
// $ae_sess.auth__entered_username = null; // Keeping the username
$ae_sess.auth__entered_password = null;
console.log('Signed out successfully.'); console.log('Signed out successfully.');
} }
@@ -516,7 +537,7 @@ function handle_lookup_user_email({email}: {email: string}) {
oninput={(e) => $ae_sess.auth__entered_username = e.target.value} oninput={(e) => $ae_sess.auth__entered_username = e.target.value}
> >
<input <input
type="text" type="password"
class="input max-w-48" class="input max-w-48"
placeholder="Password" placeholder="Password"
value={$ae_sess.auth__entered_password ?? ''} value={$ae_sess.auth__entered_password ?? ''}
@@ -532,7 +553,12 @@ function handle_lookup_user_email({email}: {email: string}) {
> >
<!-- <LogIn class="mx-1" /> --> <!-- <LogIn class="mx-1" /> -->
<UserCheck class="mx-1" /> <UserCheck class="mx-1" />
Username Sign In {#if $ae_sess.auth__entered_user_id}
User ID
{:else}
Username
{/if}
Sign In
</button> </button>
</form> </form>

View File

@@ -1,7 +1,6 @@
<script lang="ts"> <script lang="ts">
// /** @type {import('./$types').PageData} */ // /** @type {import('./$types').PageData} */
export let data: any; export let data: any;
import { onMount } from 'svelte';
import { browser } from '$app/environment'; import { browser } from '$app/environment';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
@@ -13,7 +12,6 @@ export let lq__event_session_obj: any;
export let lq__auth__event_presenter_obj: any; export let lq__auth__event_presenter_obj: any;
if (browser) { if (browser) {
// onMount(() => {
console.log('Browser environment detected.'); console.log('Browser environment detected.');
console.log(`lq__auth__event_presenter_obj = `, $lq__auth__event_presenter_obj); console.log(`lq__auth__event_presenter_obj = `, $lq__auth__event_presenter_obj);
@@ -72,9 +70,9 @@ if (browser) {
// We need to set browser history and force all load functions to rerun. // We need to set browser history and force all load functions to rerun.
goto(new_url, {replaceState: true, invalidateAll: true}); goto(new_url, {replaceState: true, invalidateAll: true});
} }
// });
} }
// For session point of contact (moderator, chair, LCI Champions). // For session point of contact (moderator, chair, LCI Champions).
function session_sign_in() { function session_sign_in() {
console.log('Session sign in with URL values'); console.log('Session sign in with URL values');
@@ -99,6 +97,7 @@ function session_sign_in() {
// $events_slct.event_presenter_id = $events_sess.auth__person.presenter_id; // $events_slct.event_presenter_id = $events_sess.auth__person.presenter_id;
} }
// For presenters within a session presentation. // For presenters within a session presentation.
function presenter_sign_in() { function presenter_sign_in() {
console.log('Presenter sign in with URL values'); console.log('Presenter sign in with URL values');
@@ -135,6 +134,7 @@ function presenter_sign_in() {
$events_loc.auth__person.presenter_id = $events_sess.auth__person.presenter_id; $events_loc.auth__person.presenter_id = $events_sess.auth__person.presenter_id;
} }
function sign_out() { function sign_out() {
$ae_loc.authenticated_access = false; $ae_loc.authenticated_access = false;
$ae_loc.access_type = 'anonymous'; $ae_loc.access_type = 'anonymous';