wildebeest/frontend/src/routes/layout.tsx

34 wiersze
757 B
TypeScript
Czysty Zwykły widok Historia

import { component$, Slot } from '@builder.io/qwik'
import { loader$ } from '@builder.io/qwik-city'
2023-03-06 16:24:39 +00:00
type AuthLoaderData = {
loginUrl: URL
isAuthorized: boolean
}
2023-03-08 09:46:21 +00:00
export const authLoader = loader$<Promise<AuthLoaderData>>(async ({ platform }) => {
2023-03-07 15:45:52 +00:00
const isAuthorized = platform.data.connectedActor !== null
2023-03-08 09:46:21 +00:00
// defined in migrations/0010_add_ui_client.sql
2023-03-06 16:24:39 +00:00
const UI_CLIENT_ID = '924801be-d211-495d-8cac-e73503413af8'
const params = new URLSearchParams({
2023-03-08 09:46:21 +00:00
redirect_uri: '/',
2023-03-06 16:24:39 +00:00
response_type: 'code',
client_id: UI_CLIENT_ID,
scope: 'all',
})
const loginUrl = new URL('/oauth/authorize?' + params, 'https://' + platform.DOMAIN)
return {
isAuthorized,
2023-03-06 16:24:39 +00:00
loginUrl,
}
})
export default component$(() => {
return (
<>
<Slot />
</>
)
})