Skip to content

Commit

Permalink
come back to tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
ludojmj committed Mar 3, 2023
1 parent d14c759 commit 2f7643c
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 548 deletions.
14 changes: 7 additions & 7 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "vite preview"
},
"devDependencies": {
"@axa-fr/vanilla-oidc": "^6.14.8",
"@axa-fr/vanilla-oidc": "^6.15.2",
"@sveltejs/vite-plugin-svelte": "^2.0.2",
"axios": "^1.2.2",
"bootstrap": "^5.2.3",
Expand Down
529 changes: 0 additions & 529 deletions client/public/OidcServiceWorker.js

This file was deleted.

2 changes: 2 additions & 0 deletions client/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import "./variables.scss";
import { Router, Route } from "svelte-navigator";
import { crud } from "./lib/const.js";
import { userInfo } from "./lib/store.js";
import AuthWrapper from "./components/oidc/AuthWrapper.svelte";
import CrudManager from "./components/CrudManager.svelte";
import StuffCreate from "./components/StuffCreate.svelte";
Expand Down Expand Up @@ -32,4 +33,5 @@
<Error msgErr="I got lost." hasReset={true} />
</Route>
</Router>
<pre>{JSON.stringify($userInfo, null, "\t")}</pre>
</AuthWrapper>
6 changes: 3 additions & 3 deletions client/src/components/StuffList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// StuffList.svelte
import { navigate } from "svelte-navigator";
import { crud } from "../lib/const.js";
import { selectedItem, userInfo } from "../lib/store.js";
import { selectedItem, tokens } from "../lib/store.js";
export let stuff;
const handleRead = (stuffDatum) => {
Expand Down Expand Up @@ -36,7 +36,7 @@
{#each stuff.datumList || [] as stuffDatum}
<tr
id={stuffDatum.id}
class={stuffDatum.user.id === $userInfo.sub
class={stuffDatum.user.id === $tokens.idTokenPayload.sub
? "table-success"
: "table-danger"}
>
Expand Down Expand Up @@ -68,7 +68,7 @@
Read
</button>
</td>
{#if stuffDatum.user.id === $userInfo.sub}
{#if stuffDatum.user.id === $tokens.idTokenPayload.sub}
<td>
<button
class="btn btn-warning"
Expand Down
5 changes: 2 additions & 3 deletions client/src/components/oidc/AuthWrapper.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>
// AuthWrapper.svelte
import { onMount } from "svelte";
import { isAuthLoading, userInfo } from "../../lib/store.js";
import { isAuthLoading, tokens } from "../../lib/store.js";
import { getTokenAync, getUserAsync } from "../../lib/oidc.js";
import Loading from "../common/Loading.svelte";
import Login from "./Login.svelte";
Expand All @@ -16,9 +16,8 @@
<Login />
{#if $isAuthLoading}
<Loading />
{:else if $userInfo}
{:else if $tokens}
<slot />
<pre>{JSON.stringify($userInfo, null, "\t")}</pre>
{:else}
<div class="alert alert-warning">
You need to login to access this site.
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/oidc/Login.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script>
// Login.svelte
import { userInfo } from "../../lib/store.js";
import { tokens } from "../../lib/store.js";
import { loginAsync } from "../../lib/oidc.js";
import Logo from "../common/Logo.svelte";
</script>

{#if !$userInfo}
{#if !$tokens}
<main class="container text-center">
<div class="row">
<div class="col">
Expand Down
6 changes: 3 additions & 3 deletions client/src/components/oidc/Logout.svelte
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<script>
// Logout.svelte
import { userInfo } from "../../lib/store.js";
import { tokens } from "../../lib/store.js";
import { logoutAsync } from "../../lib/oidc.js";
</script>

{#if $userInfo}
{#if $tokens}
<button class="btn btn-danger" on:click={async () => await logoutAsync()}>
<span>
Logout &nbsp;

<span class="badge bg-primary">
{$userInfo.name}
{$tokens.accessTokenPayload.name}
</span>
</span>
</button>
Expand Down

0 comments on commit 2f7643c

Please sign in to comment.