Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Improve session handling for SIWE
Sebastian Martinez committed 4 years ago
commit 8ac5609c6012d020903538d5bc0501c5d016ba87
parent 6d5d508220008db73ebb9d2e76c2e9438e3d3e46
3 files changed +9 -6
modified src/App.svelte
@@ -89,7 +89,7 @@
        </Route>
        <Registrations {config} session={$session} />
        <Orgs {config} />
-
        <Seeds {config} />
+
        <Seeds {config} session={$session} />
        <Faucet {config} />
        <Users />
        <Resolver {config} />
modified src/base/seeds/Routes.svelte
@@ -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>
modified src/base/seeds/View.svelte
@@ -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 />