Skip to content
Snippets Groups Projects
Commit 4934b990 authored by Emmanuel Raviart's avatar Emmanuel Raviart
Browse files

Move session to root layout data.

parent 9801c1f6
No related branches found
No related tags found
No related merge requests found
...@@ -2,51 +2,8 @@ ...@@ -2,51 +2,8 @@
declare namespace App { declare namespace App {
interface Locals { interface Locals {
user?: User user?: import("$lib/users").User
} }
// interface Platform {} // interface Platform {}
interface Session {
advanced: boolean
apiBaseUrls: string[]
apiWebSocketBaseUrls: string[]
baseUrl: string
authenticationEnabled: boolean
childrenKey: string
familyEntityKey: string
hasGithubPersonalAccessToken: boolean
hiddenEntitiesKeyPlural?: string[]
householdEntityKey: string
legalUrl: string
matomo?: {
prependDomain?: boolean
siteId: number
subdomains?: string
url: string
}
openfiscaRepository: import("$lib/repositories").RepositoryConfig
portalUrl: string
reformName?: string
showTutorial?: boolean
taxableHouseholdEntityKey: string
territoiresUrl: string
title: string
user?: User
}
// interface Stuff {}
export interface User {
email: string // "john@doe.com"
email_verified: boolean
family_name: string // "Doe"
given_name: string // "John"
last_name: string // "Doe"
locale: string // "fr"
name: string // "John Doe"
preferred_username: string // "jdoe",
roles?: string[] // [ 'offline_access', 'default-roles-leximpact', 'uma_authorization' ],
sub: string // "12345678-9abc-def0-1234-56789abcdef0"
}
} }
...@@ -2,8 +2,9 @@ import { SvelteKitAuth } from "sk-auth" ...@@ -2,8 +2,9 @@ import { SvelteKitAuth } from "sk-auth"
import { OAuth2Provider } from "sk-auth/providers" import { OAuth2Provider } from "sk-auth/providers"
import config from "$lib/server/config" import config from "$lib/server/config"
import type { User } from "$lib/users"
type Profile = App.User type Profile = User
interface Tokens { interface Tokens {
access_token: string access_token: string
......
import type { User } from "$lib/users"
import config from "$lib/server/config" import config from "$lib/server/config"
import { oauth2Authenticator } from "$lib/server/oauth2" import { oauth2Authenticator } from "$lib/server/oauth2"
...@@ -5,7 +6,35 @@ import type { LayoutServerLoad } from "./$types" ...@@ -5,7 +6,35 @@ import type { LayoutServerLoad } from "./$types"
const { githubPersonalAccessToken, openfiscaRepository } = config const { githubPersonalAccessToken, openfiscaRepository } = config
export const load: LayoutServerLoad = async (event) => { export const load: LayoutServerLoad = async (
event,
): Promise<{
advanced: boolean
apiBaseUrls: string[]
apiWebSocketBaseUrls: string[]
baseUrl: string
authenticationEnabled: boolean
childrenKey: string
familyEntityKey: string
hasGithubPersonalAccessToken: boolean
hiddenEntitiesKeyPlural?: string[]
householdEntityKey: string
legalUrl: string
matomo?: {
prependDomain?: boolean
siteId: number
subdomains?: string
url: string
}
openfiscaRepository: import("$lib/repositories").RepositoryConfig
portalUrl: string
reformName?: string
showTutorial?: boolean
taxableHouseholdEntityKey: string
territoiresUrl: string
title: string
user?: User
}> => {
const oauth2Session = await oauth2Authenticator?.getSession(event) const oauth2Session = await oauth2Authenticator?.getSession(event)
const user = oauth2Session?.user const user = oauth2Session?.user
return { return {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment