-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRedirect.svelte
More file actions
28 lines (23 loc) · 851 Bytes
/
Redirect.svelte
File metadata and controls
28 lines (23 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<script>
import { getContext, onMount } from 'svelte'
import { goto } from '$app/navigation'
import { getDefaultSession, handleIncomingRedirect } from '@inrupt/solid-client-authn-browser'
const session = getContext('session')
const { from, redirect = '/' } = $props()
// @ts-ignore
const redirectUrl = redirect.replace(from, '')
const target = new URL(
redirectUrl !== '/' ? `/${redirectUrl}` : '/',
window?.location?.href,
).toString()
const completeLogin = async () => handleIncomingRedirect({ restorePreviousSession: true })
onMount(() => {
completeLogin().then((solidAuthInfo) => {
console.log('completing login', solidAuthInfo)
$session.init(getDefaultSession())
console.log('redirecting to', target, 'from', redirectUrl)
goto(target)
})
})
</script>
redirecting to [{target}]