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,23 +155,25 @@
Signer Signer
<Signer {messageToSign} /> <Signer {messageToSign} />
Sessions Sessions
{#if activeSession}
<div>
<h3>Active Session:</h3>
<p>Node: {activeSession.node}</p>
<p>Session Key: {activeSession.sessionKey}</p>
<p>Expiration: {activeSession.expiration}</p>
</div>
{/if}
{#each sessionStatuses as { node, sessionKey, expiration, isExpired }}
<p>
{isExpired ? "🔴" : "🟢"} Node: {node}, Session Key: {sessionKey},
Expiration: {expiration}
</p>
{/each}
{/if} {/if}
<div class="mt-4 text-center"> <div class="mt-4 text-center">
<p>{status}</p> <p>{status}</p>
</div> </div>
{#if activeSession}
<div>
<h3>Active Session:</h3>
<p>Node: {activeSession.node}</p>
<p>Session Key: {activeSession.sessionKey}</p>
<p>Expiration: {activeSession.expiration}</p>
</div>
{#if sessionStatuses}
{#each sessionStatuses as { node, sessionKey, expiration, isExpired }}
<p>
{isExpired ? "🔴" : "🟢"} Node: {node}, Session Key: {sessionKey},
Expiration: {expiration}
</p>
{/each}
{/if}
{/if}
</div> </div>
</div> </div>