Budibase is an open-source low-code platform for creating internal apps in minutes. Supports PostgreSQL, MySQL, MSSQL, MongoDB, Rest API, Docker, K8s 🚀
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

38 lines
746 B

<script>
import { onMount } from "svelte"
import { isActive, redirect } from "@roxi/routify"
import { admin, auth } from "stores/portal"
let loaded = false
$: hasAdminUser = !!$admin?.checklist?.adminUser
onMount(async () => {
await admin.init()
await auth.checkAuth()
loaded = true
})
// Force creation of an admin user if one doesn't exist
$: {
if (loaded && !hasAdminUser) {
$redirect("./admin")
}
}
// Redirect to log in at any time if the user isn't authenticated
$: {
if (
loaded &&
hasAdminUser &&
!$auth.user &&
!$isActive("./auth") &&
!$isActive("./invite")
) {
$redirect("./auth/login")
}
}
</script>
{#if loaded}
<slot />
{/if}