Improve session handling for SIWE

Signed-off-by: Sebastian Martinez <sebastinez@me.com>
This commit is contained in:
Sebastian Martinez
2022-05-18 15:45:47 +02:00
committed by Alexis Sellier
parent 6d5d508220
commit 8ac5609c60
3 changed files with 9 additions and 6 deletions
+1 -1
View File
@@ -89,7 +89,7 @@
</Route>
<Registrations {config} session={$session} />
<Orgs {config} />
<Seeds {config} />
<Seeds {config} session={$session} />
<Faucet {config} />
<Users />
<Resolver {config} />
+3 -1
View File
@@ -2,10 +2,12 @@
import { Route } from "svelte-routing";
import View from '@app/base/seeds/View.svelte';
import type { Config } from '@app/config';
import type { Session } from "@app/session";
export let config: Config;
export let session: Session | null;
</script>
<Route path="/seeds/:seed" let:params>
<View {config} host={params.seed}/>
<View {config} {session} host={params.seed}/>
</Route>
+5 -4
View File
@@ -7,18 +7,19 @@
import NotFound from "@app/NotFound.svelte";
import Clipboard from "@app/Clipboard.svelte";
import Projects from "@app/base/orgs/View/Projects.svelte";
import { session } from "@app/session";
import type { Session } from "@app/session";
import Address from "@app/Address.svelte";
import SiweConnect from "@app/SiweConnect.svelte";
import type { SeedSession } from "@app/siwe";
export let config: Config;
export let session: Session | null;
export let host: string;
let siweSession: SeedSession | null = null;
$: if ($session?.siwe) {
const entries = Object.entries($session.siwe);
$: if (session?.siwe) {
const entries = Object.entries(session.siwe);
const result = entries.find(([, session]) => session.domain === host);
if (result) {
siweSession = result[1];
@@ -122,7 +123,7 @@
<!-- User Session -->
<div class="label">Connection</div>
<div>
{#if $session?.signer}
{#if session?.signer}
{#if siweSession}
<div class="desktop">
<Address address={siweSession.address} {config} resolve />