Merge pull request #13 from JackDra/master

docs: update with SvelteKit instructions
This commit is contained in:
Darrel O'Pry 2021-06-07 19:26:52 -04:00 committed by GitHub
commit fa5e7f5a4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View file

@ -73,6 +73,18 @@ use for client side auth in an SSR application you will need to ensure it is not
{#if process.browser} <OidcContext> ..... </OidcContext> {/if}
```
## SvelteKit/SSR
Same as what is needed for Sapper (see above section). To do this, we need to import in the `script` section:
```
import { browser } from '$app/env';
```
And in the `main`:
```
{#if browser} <OidcContext> ..... </OidcContext> {/if}
```
## Contributing
Contributors are Welcome. There is a lot of value in a vendor neutral OIDC component for use by the Svelte and Sapper

View file

@ -2,7 +2,6 @@
import { writable } from 'svelte/store';
import { getContext } from 'svelte';
import oidcClient from 'oidc-client';
const { UserManager } = oidcClient;
import { onMount, onDestroy, setContext } from 'svelte';
/**
@ -121,7 +120,7 @@
automaticSilentRenew: true,
};
const userManager = new UserManager(settings);
const userManager = new oidcClient.UserManager(settings);
userManager.events.addUserLoaded(function (user) {
isAuthenticated.set(true);
accessToken.set(user.access_token);