further improved the session logic

This commit is contained in:
Samuel Andert 2023-08-29 14:02:14 +02:00
parent a749abe7ed
commit 7c9e1129c7

View File

@ -23,6 +23,14 @@
let messageToSign = { user: "Sam", loggedIn: true }; let messageToSign = { user: "Sam", loggedIn: true };
onMount(async () => { onMount(async () => {
// Load activeSession from local storage
const storedSession = localStorage.getItem("google-session");
const storedPKP = localStorage.getItem("current-pkp");
if (storedSession && storedPKP) {
activeSession = JSON.parse(storedSession);
currentPKP = JSON.parse(storedPKP);
view = "READY";
}
initialize(); initialize();
}); });
@ -147,6 +155,10 @@
Signer Signer
<Signer {messageToSign} /> <Signer {messageToSign} />
Sessions Sessions
{/if}
<div class="mt-4 text-center">
<p>{status}</p>
</div>
{#if activeSession} {#if activeSession}
<div> <div>
<h3>Active Session:</h3> <h3>Active Session:</h3>
@ -154,7 +166,7 @@
<p>Session Key: {activeSession.sessionKey}</p> <p>Session Key: {activeSession.sessionKey}</p>
<p>Expiration: {activeSession.expiration}</p> <p>Expiration: {activeSession.expiration}</p>
</div> </div>
{/if} {#if sessionStatuses}
{#each sessionStatuses as { node, sessionKey, expiration, isExpired }} {#each sessionStatuses as { node, sessionKey, expiration, isExpired }}
<p> <p>
{isExpired ? "🔴" : "🟢"} Node: {node}, Session Key: {sessionKey}, {isExpired ? "🔴" : "🟢"} Node: {node}, Session Key: {sessionKey},
@ -162,8 +174,6 @@
</p> </p>
{/each} {/each}
{/if} {/if}
<div class="mt-4 text-center"> {/if}
<p>{status}</p>
</div>
</div> </div>
</div> </div>