Add return URL's to any unauthenticated requests in the portal or builder
This commit is contained in:
parent
64496759fd
commit
71296670c2
3 changed files with 27 additions and 6 deletions
|
@ -28,7 +28,8 @@
|
||||||
!$isActive("./auth") &&
|
!$isActive("./auth") &&
|
||||||
!$isActive("./invite")
|
!$isActive("./invite")
|
||||||
) {
|
) {
|
||||||
$redirect("./auth/login")
|
const returnUrl = encodeURIComponent(window.location.pathname)
|
||||||
|
$redirect("./auth/login?", { returnUrl })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<script>
|
||||||
|
import { auth } from "stores/portal"
|
||||||
|
import { onMount } from "svelte"
|
||||||
|
import { redirect } from "@roxi/routify"
|
||||||
|
|
||||||
|
// If already authenticated, redirect away from the auth section.
|
||||||
|
// Check this onMount rather than a reactive statement to avoid trumping
|
||||||
|
// the login return URL functionality.
|
||||||
|
onMount(() => {
|
||||||
|
if ($auth.user) {
|
||||||
|
$redirect("../")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if !$auth.user}
|
||||||
|
<slot />
|
||||||
|
{/if}
|
|
@ -37,12 +37,14 @@
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
// Prevent non-builders from accessing the portal
|
// Prevent non-builders from accessing the portal
|
||||||
|
if ($auth.user) {
|
||||||
if (!$auth.user?.builder?.global) {
|
if (!$auth.user?.builder?.global) {
|
||||||
$redirect("../")
|
$redirect("../")
|
||||||
} else {
|
} else {
|
||||||
await organisation.init()
|
await organisation.init()
|
||||||
loaded = true
|
loaded = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue