Improved sign in process and UI
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
// *** Import Svelte specific
|
||||
import { browser } from '$app/environment';
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
// *** Import other supporting libraries
|
||||
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_obj: key_val = $state({}); // Use $state to ensure reactivity
|
||||
|
||||
|
||||
$effect(() => {
|
||||
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.`);
|
||||
@@ -59,6 +61,7 @@ $effect(() => {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function sign_in() {
|
||||
$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
|
||||
@@ -91,8 +94,21 @@ function sign_in() {
|
||||
...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() {
|
||||
// Clear the session information
|
||||
$ae_loc.person_id = null;
|
||||
@@ -109,6 +125,11 @@ function sign_out() {
|
||||
let access_checks_results = ae_util.process_permission_checks('');
|
||||
$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.');
|
||||
}
|
||||
|
||||
@@ -516,7 +537,7 @@ function handle_lookup_user_email({email}: {email: string}) {
|
||||
oninput={(e) => $ae_sess.auth__entered_username = e.target.value}
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
type="password"
|
||||
class="input max-w-48"
|
||||
placeholder="Password"
|
||||
value={$ae_sess.auth__entered_password ?? ''}
|
||||
@@ -532,7 +553,12 @@ function handle_lookup_user_email({email}: {email: string}) {
|
||||
>
|
||||
<!-- <LogIn 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>
|
||||
</form>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user