mirror of
https://github.com/TECHNOFAB11/svelte-oidc.git
synced 2025-12-11 23:50:06 +01:00
Merge pull request #13 from JackDra/master
docs: update with SvelteKit instructions
This commit is contained in:
commit
fa5e7f5a4e
2 changed files with 14 additions and 3 deletions
12
README.md
12
README.md
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,8 +120,8 @@
|
|||
automaticSilentRenew: true,
|
||||
};
|
||||
|
||||
const userManager = new UserManager(settings);
|
||||
userManager.events.addUserLoaded(function(user) {
|
||||
const userManager = new oidcClient.UserManager(settings);
|
||||
userManager.events.addUserLoaded(function (user) {
|
||||
isAuthenticated.set(true);
|
||||
accessToken.set(user.access_token);
|
||||
idToken.set(user.id_token);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue